I need an indexed associative container that operates as follows:
initially empty, size=0.
when I add a new element to it, it places it at index [size], very similar to a vector's push_back. It increments the size and returns the index of the newly added element.
if the element already exists, it returns the index where it occurs.
Set seems the ideal data structure for this but I don't see any thing like getting an index from a find operation. Find on a set returns an iterator to the element.
Will taking the difference with set.begin() be the correct thing to do in this situation?