Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
How Hash Tables Work: Writing Your Own HashMap in C#, Collisions and Load Factor
A hash table computes a bucket index from the key's hash code and resolves collisions with chaining or open addressing; a GetHashCode that always returns 42 makes a 10,000-key Dictionary 967 times slower. We write our own HashMap with the same internals as .NET's Dictionary (buckets + entries, free list, prime sizes), linear probing with tombstones, look at randomized string hashing and build a Bloom filter, all with xUnit tests.
C# Dictionary and HashSet: TryGetValue, Key Equality and Comparers
How a Dictionary finds a key with GetHashCode and Equals, and why a class key without equality bloats it. The differences between Add, the indexer, TryAdd and TryGetValue, counting in a single lookup with .NET 6 CollectionsMarshal, the mutable key trap, OrdinalIgnoreCase and the Turkish I trap, ordering, and HashSet set operations.