| #define | DKHASH_WALK_REMOVE 1 |
| | return flags usable from the callback function of dkhash_walk_data()
|
| |
|
#define | DKHASH_WALK_STOP 2 |
| | Cause walking to stop.
|
| |
| #define | DKHASH_OK 0 |
| | return values for dkhash_insert()
|
| |
|
#define | DKHASH_EDUPE (-EPERM) |
| | duplicate insert attempted
|
| |
|
#define | DKHASH_EPERM (-EPERM) |
| | duplicate insert attempted
|
| |
|
#define | DKHASH_EINVAL (-EINVAL) |
| | Invalid parameters passed.
|
| |
|
#define | DKHASH_ENOMEM (-ENOMEM) |
| | Memory allocation failed.
|
| |
|
typedef struct dkhash_table | dkhash_table |
| | opaque type
|
| |
| dkhash_table * | dkhash_create (unsigned int size) |
| | Create a dual-keyed hash-table of the given size Note that it's generally useful to make the table 25-30% larger than the number of items you intend to store, and also note that the 'size' arguments gets rounded up to the nearest power of 2.
|
| |
| int | dkhash_destroy (dkhash_table *t) |
| | Destroy a dual-keyed hash table.
|
| |
| void * | dkhash_get (dkhash_table *t, const char *k1, const char *k2) |
| | Fetch the data associated with a particular key.
|
| |
| int | dkhash_insert (dkhash_table *t, const char *k1, const char *k2, void *data) |
| | Insert a new entry into the hash table.
|
| |
| void * | dkhash_remove (dkhash_table *t, const char *k1, const char *k2) |
| | Remove data from the hash table Note that this does not free() the pointer to the data stored in the table.
|
| |
| void | dkhash_walk_data (dkhash_table *t, int(*walker)(void *data)) |
| | Call a function once for each item in the hash-table The callback function can return DKHASH_WALK_{REMOVE,STOP} or any OR'ed combination thereof to control the walking procedure, and should return 0 on the normal case.
|
| |
| unsigned int | dkhash_collisions (dkhash_table *t) |
| | Get number of collisions in hash table Many collisions is a sign of a too small hash table or poor hash-function.
|
| |
| unsigned int | dkhash_num_entries (dkhash_table *t) |
| | Get number of items in the hash table.
|
| |
| unsigned int | dkhash_num_entries_max (dkhash_table *t) |
| | Get max number of items stored in the hash table.
|
| |
| unsigned int | dkhash_num_entries_added (dkhash_table *t) |
| | Get number of entries added to hash table Note that some of them may have been removed.
|
| |
| unsigned int | dkhash_num_entries_removed (dkhash_table *t) |
| | Get number of removed items from hash table.
|
| |
| unsigned int | dkhash_table_size (dkhash_table *t) |
| | Get actual table size (in number of buckets)
|
| |
Dual-key hash functions for Nagios.
Having a dual-key hash function is pretty unusual, but since so much data in Nagios pertains to services (which are uniquely identified based on both host_name and service_description), it makes sense here.