c++ unordered_map collision handling , resize and rehash

后端 未结 3 2154
旧时难觅i
旧时难觅i 2021-02-13 04:10

I have not read the C++ standard but this is how I feel that the unordered_map of c++ suppose to work.

  • Allocate a memory block in the heap.
  • With every p
3条回答
  •  无人及你
    2021-02-13 04:46

    std::unordered_map contains a load factor that it uses to manage the size of it's internal buckets. std::unordered_map uses this odd factor to keep the size of the container somewhere in between a 0.0 and 1.0 factor. This decreases the likelihood of a collision in a bucket. After that, I'm not sure if they fallback to linear probing within a bucket that a collision was found in, but I would assume so.

提交回复
热议问题