Ordered and unordered STL containers

What is the difference between ordered and unordered STL containers?

+3
source share
7 answers

Ordered and unordered belong to containers transitively.

What interests you is Sequence, that is, the order in which the elements will appear when you iterate over (possibly part of) the container.

The sequence, however, is more general, therefore for this kind of concept I will refer to a copy of Martin Broadhurst on the SGI STL website (the mother of the current STL), when you can find the taxonomy of the various concepts that are hidden behind the STL.

. , , , , , , . , , , , . .

1 - , , , , .

, . . SGI STL , , . . , , , .

- , Boost ++ 0x, , hash_set hash_map. , , SGI STL, Hashed.

: , , , () . , , . , Python dict .


1 . , , set , , ...

+3

, , , .

.

+6

STL . , std:: set - . STL -, unordered_set - -.

, , . , . .

, , , , .

+4

(tr1::unordered_map tr1::unordered_set) , , -. O (1).

(std::map std::set) node. O (log) time.

+1

-: , std::(map|set) vs 0x std::unordered_(map|set) , : - , . , , - ( , ). ( , ), (.. ). , , ( ) - , .

+1

- . operator<, Traits operator(). . Predicate. ( ).

0

, ( ) - . , .

0

Source: https://habr.com/ru/post/1785506/


All Articles