Boost logo

Boost Users :

Subject: Re: [Boost-users] Correct use of unordered_map
From: Daniel James (daniel_james_at_[hidden])
Date: 2009-09-02 04:10:53


2009/9/1 John Dlugosz <JDlugosz_at_[hidden]>:
>
> 1) is end unchanging, or must you call end() every time rather than remembering it?

As long as you don't call a method which can invalidate it, it's fine.
Erase won't invalidate the end iterator.

> 2) does resuming iteration from the "successor" traverse the remaining elements?
>
> The wording is copied from the plain map class, which is ordered and the ordering definition of the iterators makes #2 well defined.  That is not the case for the unordered_map.

Changing the order of the elements would invalidate iterators so it's
safe to say that the order of elements that haven't been erased will
remain the same. But be careful with other methods.

> I might argue that even "successor" is not defined on this type.

You might, but you probably shouldn't.

Daniel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net