How to access element in Multiset by index
-
Is it possible to access element by index (like in array or vector), when using multiset?
no but you can walk through the collection with an iterator.
-
Is it possible to access element by index (like in array or vector), when using multiset?
as you've already started discussion on same topic, please continue your discussion in previous thread. multiset is a node based container. It's not implemented using contigeous memory allocation. Please check the documentation of multiset.
-Sarath. "Great hopes make everything great possible" - Benjamin Franklin
My blog - Sharing My Thoughts
-
no but you can walk through the collection with an iterator.
I found, that it is possible only to iterate in this way:
multiset s;
multiset::iterator it;it = s.begin();
for (int i = 0; i < s.size(); ++i)
it++;I tried to do the following:
it += k;
But that doesn't work. Is there any oppotunity to "jump" to the position?