raychenv / blog

my simple blog
1 stars 0 forks source link

unordered_map #348

Open raychenv opened 1 year ago

raychenv commented 1 year ago

https://github.com/raychenv/LightDB/blob/main/src/dataBase.cpp

Unordered map is an associative container that contains key-value pairs with unique keys. Search, insertion, and removal of elements have average constant-time complexity.

Internally, the elements are not sorted in any particular order, but organized into buckets. Which bucket an element is placed into depends entirely on the hash of its key. Keys with the same hash code appear in the same bucket. This allows fast access to individual elements, since once the hash is computed, it refers to the exact bucket the element is placed into.

Two keys are considered equivalent if the map's key equality predicate returns true when passed those keys. If two keys are equivalent, the hash function must return the same value for both keys.

https://en.cppreference.com/w/cpp/container/unordered_map https://www.educative.io/answers/how-to-implement-a-hash-table-in-cpp https://www.modernescpp.com/index.php/hash-tables https://en.wikipedia.org/wiki/Self-balancing_binary_search_tree

https://www.modernescpp.com/index.php/associative-containers-a-simple-performance-comparison