1 #ifndef OSRF_BIG_HASH_H
2 #define OSRF_BIG_HASH_H
5 #include <opensrf/utils.h>
6 #include <opensrf/string_array.h>
12 #define OSRF_HASH_MAXKEY 256
14 struct __osrfBigHashStruct {
15 Pvoid_t hash; /* the hash */
16 void (*freeItem) (char* key, void* item); /* callback for freeing stored items */
18 typedef struct __osrfBigHashStruct osrfBigHash;
21 struct __osrfBigHashIteratorStruct {
25 typedef struct __osrfBigHashIteratorStruct osrfBigHashIterator;
28 Allocates a new hash object
30 osrfBigHash* osrfNewBigHash();
33 Sets the given key with the given item
34 if "freeItem" is defined and an item already exists at the given location,
35 then old item is freed and the new item is put into place.
36 if "freeItem" is not defined and an item already exists, the old item
38 @return The old item if exists and there is no 'freeItem', returns NULL
41 void* osrfBigHashSet( osrfBigHash* hash, void* item, const char* key, ... );
44 Removes an item from the hash.
45 if 'freeItem' is defined it is used and NULL is returned,
46 else the freed item is returned
48 void* osrfBigHashRemove( osrfBigHash* hash, const char* key, ... );
50 void* osrfBigHashGet( osrfBigHash* hash, const char* key, ... );
54 @return A list of strings representing the keys of the hash.
55 caller is responsible for freeing the returned string array
56 with osrfStringArrayFree();
58 osrfStringArray* osrfBigHashKeys( osrfBigHash* hash );
63 void osrfBigHashFree( osrfBigHash* hash );
66 @return The number of items in the hash
68 unsigned long osrfBigHashGetCount( osrfBigHash* hash );
74 Creates a new list iterator with the given list
76 osrfBigHashIterator* osrfNewBigHashIterator( osrfBigHash* hash );
79 Returns the next non-NULL item in the list, return NULL when
80 the end of the list has been reached
82 void* osrfBigHashIteratorNext( osrfBigHashIterator* itr );
85 Deallocates the given list
87 void osrfBigHashIteratorFree( osrfBigHashIterator* itr );
89 void osrfBigHashIteratorReset( osrfBigHashIterator* itr );