1. 34

  2. 6

    On the same vibe, I loved watching this video from Jon Gjengset about implementing a linked hash map in Rust: https://www.youtube.com/watch?v=k6xR2kf9hlA

    1. 1

      This explains how to deal with collisions on insertion, but I don’t see how accessing won’t just return the first item inserted when there’s a collision.

      1. 1

        This is handled in ht_get with a while loop: we start at the index hash%capacity, and then loop till the key there is equal to the one we’re looking for. If we keep looping and find an empty slot instead, we know it’s key-not-found.