[LLVMdev] Question about SparseMultiSet

Michael Ilseman milseman at apple.com
Fri Aug 2 10:41:23 PDT 2013


Sorry for the late reply.

On Jul 26, 2013, at 3:26 PM, Micah Villmow <micah.villmow at smachines.com> wrote:

> Does anyone know if an insertion invalidates the end() iterator? The documentation  in ADT/SparseMultiSet.h mentions that removal only invalidates the iterator of the object being removed, but nothing on insertion. My understanding from reading the code seems to me that it doesn’t invalidate it, but I want to make sure as I’m not 100% sure here.

You are correct. 

From the documentation:
  The doubly linked list is implemented circular in Prev indices, and INVALID-terminated in Next indices.

Insertion will modify the Next index of the tail of the list for that key, and assigning it the index of the newly inserted entry.

Of course, if you had walked an iterator off the end of one of these lists (and thus, it's INVALID/equal to end()), that iterator will not be magically updated to point to the newly inserted value. This behavior is consistent with other set-like data structures.

Feel free to ask me if you have any questions.


>  
> Thanks,
> Micah
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130802/62c6759a/attachment.html>


More information about the llvm-dev mailing list