Hash map optimized for search

I am looking for a card that has fixed keys (fixed during initialization), and this speeds up the search. It may not support adding / updating items later. Is there some kind of algorithm that looks through the list of keys and formulates a function to search faster later. In my case, the keys are strings.

Update:

Keys are not known at compile time. But during application initialization. After that there will be no additional inserts, but there will be many searches. Therefore, I want to optimize the optimization.

+5
source share
4 answers

CMPH , . gperf, .

, , std::unordered_map, ++ 11, , , , .

, , trie ( trie-, - , ), , . trie. , - , , . , , . - ( , ) . trie/trie- , node.

( , O (log (N)) , , , O (1) , big-O .)

+2

, : , , -, ? , .


-, (.. , ). - (, this, this). -.

- (, shift-multiply-add) .

( , ).

- - , , , . , -.

+1

google-sparsehash: http://code.google.com/p/google-sparsehash/

An extremely memory-efficient hash_map implementation. 2 bits/entry overhead! 
The SparseHash library contains several hash-map implementations, including 
implementations that optimize for space or speed.
0

In a similar topic ((number) of elements known at compile time), I did the following: Search by a known set of integer keys . Low overhead, no perfect hash needed. Fortunately, it is in C; -)

0
source

All Articles