Hashing Library for C

I try to find some Hashing libraries for C and find several good ones.

The hsearch function in the GNU C library.

There are other methods to organize information which later should be searched. The costs of insert, delete and search differ. One possible implementation is using hashing tables. The following functions are declared in the header file search.h.

CMPH – C Minimal Perfect Hashing Library.

The CMPH Library encapsulates the newest and more efficient algorithms in an easy-to-use, production-quality, fast API. The library was designed to work with big entries that cannot fit in the main memory. It has been used successfully for constructing minimal perfect hash functions for sets with more than 100 million of keys, and we intend to expand this number to the order of billion of keys.

libghthash.

libghthash is a Generic Hash Table which is meant to be easy to extend, portable, clear in its code and easy to use. You can store any kind of data in it, regardless of size etc. It should be fairly portable, and has been successfully tried on Linux/x86, Solaris/SPARC and Win2000/x86 so far.

Eric Zhiqiang Ma

Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

One comment:

  1. An example of a piece of code using libghthash:

        ght_hash_table_t *tx_table = NULL;
        ppm_tx_id_t txid;
    
        // prepare the hash table
        tx_table = ght_create(HASH_TABLE_SIZE);
    
        // allow rehash. Note: rehashing is costly.
        ght_set_rehash(tx_table, TRUE);
    
    
        ...
    
    
        // check the hash whether the txid key exists
        pdata = ght_get(tx_table,
                sizeof(ppm_tx_id_t), &(txid));
    
        if (pdata != NULL) {
            // replace the entry in the hash table
            ght_replace(tx_table,
                    &type_b,
                    sizeof(ppm_tx_id_t), &(txid));
        } else {
            // insert to the hash
            ght_insert(tx_table,
                    &type_b,
                    sizeof(ppm_tx_id_t), &(txid));
        }
    

Leave a Reply

Your email address will not be published. Required fields are marked *