122 bool* buckets_in_use; |
124 bool* buckets_in_use; |
123 }; |
125 }; |
124 |
126 |
125 /* Call these function to manipulate a hash */ |
127 /* Call these function to manipulate a hash */ |
126 |
128 |
127 /* Deletes the value with the specified key pair from the hash and returns |
129 /** Deletes the value with the specified key pair from the hash and returns |
128 * that value. Returns NULL when the value was not present. The value returned |
130 * that value. Returns NULL when the value was not present. The value returned |
129 * is _not_ free()'d! */ |
131 * is _not_ free()'d! */ |
130 void* Hash_Delete(Hash* h, uint key1, uint key2); |
132 void* Hash_Delete(Hash* h, uint key1, uint key2); |
131 /* Sets the value associated with the given key pair to the given value. |
133 /** Sets the value associated with the given key pair to the given value. |
132 * Returns the old value if the value was replaced, NULL when it was not yet present. */ |
134 * Returns the old value if the value was replaced, NULL when it was not yet present. */ |
133 void* Hash_Set(Hash* h, uint key1, uint key2, void* value); |
135 void* Hash_Set(Hash* h, uint key1, uint key2, void* value); |
134 /* Gets the value associated with the given key pair, or NULL when it is not |
136 /** Gets the value associated with the given key pair, or NULL when it is not |
135 * present. */ |
137 * present. */ |
136 void* Hash_Get(const Hash* h, uint key1, uint key2); |
138 void* Hash_Get(const Hash* h, uint key1, uint key2); |
137 |
139 |
138 /* Call these function to create/destroy a hash */ |
140 /* Call these function to create/destroy a hash */ |
139 |
141 |
140 /* Builds a new hash in an existing struct. Make sure that hash() always |
142 /** Builds a new hash in an existing struct. Make sure that hash() always |
141 * returns a hash less than num_buckets! Call delete_hash after use */ |
143 * returns a hash less than num_buckets! Call delete_hash after use */ |
142 void init_Hash(Hash* h, Hash_HashProc* hash, uint num_buckets); |
144 void init_Hash(Hash* h, Hash_HashProc* hash, uint num_buckets); |
143 /* |
145 /** |
144 * Deletes the hash and cleans up. Only cleans up memory allocated by new_Hash |
146 * Deletes the hash and cleans up. Only cleans up memory allocated by new_Hash |
145 * & friends. If free is true, it will call free() on all the values that |
147 * & friends. If free is true, it will call free() on all the values that |
146 * are left in the hash. |
148 * are left in the hash. |
147 */ |
149 */ |
148 void delete_Hash(Hash* h, bool free_values); |
150 void delete_Hash(Hash* h, bool free_values); |
149 /* |
151 /** |
150 * Cleans the hash, but keeps the memory allocated |
152 * Cleans the hash, but keeps the memory allocated |
151 */ |
153 */ |
152 void clear_Hash(Hash* h, bool free_values); |
154 void clear_Hash(Hash* h, bool free_values); |
153 /* |
155 /** |
154 * Gets the current size of the Hash |
156 * Gets the current size of the Hash |
155 */ |
157 */ |
156 uint Hash_Size(const Hash* h); |
158 uint Hash_Size(const Hash* h); |
157 |
159 |
158 #endif /* QUEUE_H */ |
160 #endif /* QUEUE_H */ |