Thursday, May 14, 2020

Hash libraries for C Programmers

This page lists a collection of libraries that will help you in programming in C. Libraries here are open source and used to help you store data, without having to roll your own linked list etc data structures. uthash Developed by Troy D. Hanson, any C structure can be stored in a hash table using uthash. Just include #include uthash.h then add a UT_hash_handle to the structure and choose one or more fields in your structure to act as the key. Then use HASH_ADD_INT, HASH_FIND_INT and macros to store, retrieve or delete items from the hash table. It uses int, string and binary keys. Judy Judy is a C library that implements a sparse dynamic array. Judy arrays are declared simply with a null pointer and consume  memory only when populated. They can grow to use all available memory if desired. Judys key benefits are scalability, high performance, and memory efficiency. It can be used for dynamically sized arrays, associative arrays or a simple-to-use interface that requires no rework for expansion or contraction and can replace many common data structures, such as arrays, sparse arrays, hash tables, B-trees, binary trees, linear lists, skiplists, other sort and search algorithms, and counting functions. SGLIB SGLIB is short for  Simple Generic Library and consists of a single header file sglib.h that provides generic implementation of most common algorithms for arrays, lists, sorted lists and red-black trees. The library is generic and it does not define its own data structures. Rather it acts on existing user-defined data structures via a generic interface. It also does not allocate or deallocate any memory and does not depend on any particular memory management. All algorithms are implemented in form of macros parametrized by the type of data structure and comparator function (or comparator macro). Several further generic parameters such as the name of next field for linked lists may be required for some algorithms and data structures.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.