dictionary - C++ STL associative containers: Get iterator from element? -
this has been asked vectors. possible sets & co too?
c.equal_range(elem);
for set-like, or
c.equal_range(elem.first);
for map-type containers return pair of iterators equivalent (under container's rules) element. takes between o(k) , o(lg n) time, n number of elements in container, , k number of elements pseudo-equivalent elem
/elem.first
(pseudo, hash collisions modulo bucket count count). average constant (for unordered)/lg n (for ordered).
Comments
Post a Comment