-1

In the QLinkedList's insert function, it returns an iterator

iterator QLinkedList::insert(iterator before, const T &value)

is the returned iterator permanent? Can I find the original value I inserted by using the returned iterator? Even after I insert/delete many other items into/from the list?

Nyaruko
  • 4,329
  • 9
  • 54
  • 105

1 Answers1

1

From the documentation I suppose that the QList::iterator is not "permanent", while the QLinkedList::iterator is in some cases.

For QList

Multiple iterators can be used on the same list. However, be aware that any non-const function call performed on the QList will render all existing iterators undefined. If you need to keep iterators over a long period of time, we recommend that you use QLinkedList rather than QList.

For QLinkedList

Multiple iterators can be used on the same list. If you add items to the list, existing iterators will remain valid. If you remove items from the list, iterators that point to the removed items will become dangling iterators.

See QList::iterator and QLinkedList::iterator

Fabio
  • 2,522
  • 1
  • 15
  • 25