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.
CMPH , . gperf, .
gperf
, , std::unordered_map, ++ 11, , , , .
std::unordered_map
, , trie ( trie-, - , ), , . trie. , - , , . , , . - ( , ) . trie/trie- , node.
( , O (log (N)) , , , O (1) , big-O .)
, : , , -, ? , .
-, (.. , ). - (, this, this). -.
- (, shift-multiply-add) .
( , ).
- - , , , . , -.
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.
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; -)