O (1) search in C ++

Is there a data structure in C ++ with search O(1)?

A std::maphas O(log(n))a search time (right?).

I look from something in stdpreferably (so not Boost pls). Also, if there is, how does it work?

EDIT: Well, I was not clear enough, I think. I want to bind values, sort of like in map. Therefore, I need something like std::map<int,string>that, findand I inserthave to accept it O(1).

+3
source share
3 answers

Arrays have an O (1) search. Hashtable (std :: unordered_map) for C ++ 11 has an O (1) lookup. (Depreciated, but more or less constant.)

, , , log (n), .

→ . - , ( 1 ) .

, : (- , - , ). , . - , .

+10

O (1) ( ) :

  • -

O (log n), patricia trie O ().

:

+4

array has a O(1)search.

+3
source

All Articles