What's the point of a hash table?

后端 未结 11 1506
耶瑟儿~
耶瑟儿~ 2020-12-28 17:01

I don\'t have experience with hash tables outside of arrays/dictionaries in dynamic languages, so I recently found out that internally they\'re implemented by making a hash

11条回答
  •  死守一世寂寞
    2020-12-28 17:19

    This is a near duplicate: Why do we use a hashcode in a hashtable instead of an index?

    Long story short, you can check if a key is already stored VERY quickly, and equally rapidly store a new mapping. Otherwise you'd have to keep a sorted list of keys, which is much slower to store and retrieve mappings from.

提交回复
热议问题