uthash 1.9.7

A hash for C structures

  Add it to your Download Basket!

 Add it to your Watch List!

0/5

Rate it!

What's new in uthash 1.9.7:

  • A number of small enhancements were made to the supplemental utilities included with uthash, including new list operations (prepend, replace, and support for structures that use different naming conventions), new dynamic string features (KMP substring search, format checking), compatibility improvements, and improved documentation.
Read full changelog
send us
an update
LICENSE TYPE:
BSD License 
USER RATING:
3.0/5 9
DEVELOPED BY:
Troy D. Hanson
HOMEPAGE:
uthash.sourceforge.net
CATEGORY:
ROOT \ Utilities
1 uthash Screenshot:
uthash
uthash is a hash for C structures, allowing any C structure having a unique key field to be hashed.

Structures can be deleted, added or removed from the hash in constant time. The key field can have any data type.

Example 1. Adding an item to a hash.

#include "uthash.h"

struct my_struct {
int id; /* key */
char name[10];
UT_hash_handle hh; /* makes this structure hashable */
};

struct my_struct *users = NULL;

void add_user(struct my_struct *s) {
HASH_ADD_INT( users, id, s ); /* hash, key field name, item */
}


Example 2. Looking up an item in a hash.

struct my_struct *find_user(int user_id) {
struct my_struct *s;

HASH_FIND_INT( users, s, id, &user_id );
return s;
}


Example 1. Deleting an item from a hash.

void delete_user(struct my_struct *user) {
HASH_DEL( users, user); /* hash, pointer to deletee */
}

Last updated on October 9th, 2012

#C structures hash #unique key field #hashed keys #uthash #C+ #structures #hash

Add your review!

SUBMIT