Mac / iPhone App Development
Home of a Small Time Developer

SieveHash – An alternative hash table implementation

A fast and efficient C hash table implementation, which in many cases can beat google dense hash map, the STL Tr1 hash map and khash

The semi-interesting part is the way it handles collisions. When Sievehash encounters a collision is makes another hash table smaller than it’s parent. Each new key is dropped through the Seive until an empty spot is found and becomes it’s new home, forming a structure like a Seive.

Similar to most hash tables, when any table reaches the specified load factor all keys will be copied to a new larger table.

Sieve Hash Library: SieveHash.h

Hash test package: HashTests

*** Starting String Test: STL TR1
- Insert Took: 2.751855
- Lookup Took: 2.694130
} Test Took: 8.425282
*** Starting String Test: SieveHash
- Insert Took: 4.447270
- Lookup Took: 2.972444
} Test Took: 10.369791
*** Starting String Test: KHash CPP
- Insert Took: 2.676008
- Lookup Took: 3.056431
} Test Took: 8.704912
*** Starting String Test: Google Dense Hash Test
- Insert Took: 5.109226
- Lookup Took: 4.746739
} Test Took: 12.817609
WARNING: This is not meant for production code, it is for testing purposes only.

Leave a Reply