1 /* 2 * %CopyrightBegin% 3 * 4 * Copyright Ericsson AB 1998-2016. All Rights Reserved. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 * %CopyrightEnd% 19 * 20 21 */ 22 #ifndef _HASH_H 23 #define _HASH_H 24 25 #include <stdio.h> 26 27 #include "ei.h" /* We need our types there */ 28 29 #define ei_hash_size(tab) ((tab)->size) 30 #define ei_hash_count(tab) ((tab)->count) 31 32 #define ALIGN_QUAD 0x7 33 #define ei_align(size) while (((unsigned)size) & ALIGN_QUAD) (size)++ 34 35 int ei_isprime(int n); 36 int ei_dohash(const char *key); 37 void *ei_hash_lookup(ei_hash *tab, const char *key); 38 const char *ei_hash_rlookup(ei_hash *tab, const void *value); 39 int ei_hash_foreach(ei_hash *tab, int (*f)(const char *key, const void *value)); 40 void *ei_hash_insert(ei_hash *tab, const char *key, const void *value); 41 void *ei_hash_remove(ei_hash *tab, const char *key); 42 ei_hash *ei_hash_newtab(int tabsize); 43 ei_hash *ei_hash_resize(ei_hash *oldtab, int newsize); 44 int ei_hash_freetab(ei_hash *tab, void (*f)(void *)); 45 void ei_hash_stats(ei_hash *tab, FILE *out); 46 void ei_hash_bfree(ei_hash *tab, ei_bucket *b); 47 48 #endif /* _HASH_H */ 49