Saturday, 15 August 2015

c++ - simple unique STL container -



c++ - simple unique STL container -

is there unique container such std::list simple functionality (push,pop,clear, etc.) , not sorted order unlike std::set, or maybe need extend std::list , add together own push_unique method )) ?

the stl supposed provide efficient containers.

a container not allow duplicates needs back upwards fast lookup determine whether value want nowadays in collection or not.

std::set keeps item sorted in red-black tree, allows o(log(n)) lookup, insertion, , removal.

std::unsorted_set allows constant-time lookup, insertion, , removal, need provide hash function udt types, need take care of issues such rehashing, cause iterator invalidation, , not have defined order items (not insertion order).

if want utilize simple collection such std::vector without allowing duplicates, need provide own adapter.

however, still can't figure out why have problems sorted container such std::set if, say, order doesn't matter you.

c++ stl

No comments:

Post a Comment