5 #include "opensrf/utils.h"
6 #include "opensrf/string_array.h"
8 #define OSRF_HASH_MAXKEY 256
10 struct __osrfBigHashStruct {
11 Pvoid_t hash; /* the hash */
12 void (*freeItem) (char* key, void* item); /* callback for freeing stored items */
14 typedef struct __osrfBigHashStruct osrfBigHash;
17 struct __osrfBigHashIteratorStruct {
21 typedef struct __osrfBigHashIteratorStruct osrfBigHashIterator;
24 Allocates a new hash object
26 osrfBigHash* osrfNewBigHash();
29 Sets the given key with the given item
30 if "freeItem" is defined and an item already exists at the given location,
31 then old item is freed and the new item is put into place.
32 if "freeItem" is not defined and an item already exists, the old item
34 @return The old item if exists and there is no 'freeItem', returns NULL
37 void* osrfBigHashSet( osrfBigHash* hash, void* item, const char* key, ... );
40 Removes an item from the hash.
41 if 'freeItem' is defined it is used and NULL is returned,
42 else the freed item is returned
44 void* osrfBigHashRemove( osrfBigHash* hash, const char* key, ... );
46 void* osrfBigHashGet( osrfBigHash* hash, const char* key, ... );
50 @return A list of strings representing the keys of the hash.
51 caller is responsible for freeing the returned string array
52 with osrfStringArrayFree();
54 osrfStringArray* osrfBigHashKeys( osrfBigHash* hash );
59 void osrfBigHashFree( osrfBigHash* hash );
62 @return The number of items in the hash
64 unsigned long osrfBigHashGetCount( osrfBigHash* hash );
70 Creates a new list iterator with the given list
72 osrfBigHashIterator* osrfNewBigHashIterator( osrfBigHash* hash );
75 Returns the next non-NULL item in the list, return NULL when
76 the end of the list has been reached
78 void* osrfBigHashIteratorNext( osrfBigHashIterator* itr );
81 Deallocates the given list
83 void osrfBigHashIteratorFree( osrfBigHashIterator* itr );
85 void osrfBigHashIteratorReset( osrfBigHashIterator* itr );