Random-access iterators implement all the functionality of bidirectional iterators, and also have the ability to access ranges non-sequentially: distant elements can be accessed directly by applying an offset value to an iterator without iterating through all the elements in between.

Then again, vectors are most frequently added to at the end of the container, so there's normally nothing to invalidate.) Deletion from a vector invalidates that iterator and all iterators past it.

Well, it's implementation dependent and there might be some implementer that does something else (perhaps using malloc to reserve a piece of memory and then use placement new or something).

The point is that it is not defined in the standard so it can be done however you wish as long as it's compliant, however an array is probably the easiest and best way to do it.

-- Erik Wikstrm Well, it's implementation dependent and there might be some implementer that does something else (perhaps using malloc to reserve a piece of memory and then use placement new or something).

To retrieve the end of a directory, the class must be instantiated with the default constructor.

Entries can be created or deleted while iterating without invalidating the iterator.

If I insert/remove an element in a set, will an iterator to this set automatically become invalid? For vectors, insertion may invalidate _all_ iterators into the vector if the insertion requires a reallocation.

Does the position of the iterator before the insertion/removal matter? (Hadn't thought about it, but it would invalidate all iterators at the point of insertion and beyond in all cases.

No contained elements are accessed by the call, but the iterator returned can be used to access or modify elements.