Results 1 to 2 of 2

Thread: Implicit sharing iterator problem with QVector and QHash

  1. #1
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question Implicit sharing iterator problem with QVector and QHash

    Hello

    What should one pay attention to in order to avoid the Implicit sharing iterator problem in the case of QVector? same question for QHash?

    Can I do:

    QVector<int> a;
    Qvector<int> b;

    a.push_back(0);
    a.push_back(1);

    b.push_back(2);
    b.push_back(3);

    //iterate trough a
    //iterate trough b
    // remove one element in b

    a = b;

    What are the restrictions when assigning one QVector to another one?

    Thank you in advance for any hints/help.

    Mut.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Implicit sharing iterator problem with QVector and QHash

    Can you elaborate what the "Implicit sharing iterator problem" is?

    Your code creates one vector with two element, one with four, then iterates over both, then reduces the size of the four element vector to three and then overwrites the two element vector.

    What exactly is problematic there?

    Cheers,
    _

Similar Threads

  1. Implicit sharing vs. c++ refereces
    By IrYoKu in forum Qt Programming
    Replies: 12
    Last Post: 9th November 2011, 23:20
  2. Threads and Implicit Sharing
    By stillwaiting in forum Newbie
    Replies: 5
    Last Post: 30th November 2010, 16:46
  3. QVector::data() and implicit sharing
    By abernat in forum Qt Programming
    Replies: 2
    Last Post: 7th July 2009, 18:34
  4. Question about implicit sharing
    By Cruz in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2009, 17:03
  5. QSharedData - implicit sharing
    By gyre in forum Newbie
    Replies: 4
    Last Post: 28th October 2007, 19:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.