cctools
itable.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3 Copyright (C) 2022 The University of Notre Dame
4 This software is distributed under the GNU General Public License.
5 See the file COPYING for details.
6 */
7 
8 #ifndef ITABLE_H
9 #define ITABLE_H
10 
11 #include "int_sizes.h"
12 
56 struct itable *itable_create(int buckets);
57 
63 void itable_clear( struct itable *h, void (*delete_func)(void*) );
64 
70 void itable_delete(struct itable *h);
71 
77 int itable_size(struct itable *h);
78 
89 int itable_insert(struct itable *h, UINT64_T key, const void *value);
90 
97 void *itable_lookup(struct itable *h, UINT64_T key);
98 
105 void *itable_remove(struct itable *h, UINT64_T key);
106 
112 void * itable_pop( struct itable *h );
113 
121 void itable_firstkey(struct itable *h);
122 
131 int itable_nextkey(struct itable *h, UINT64_T * key, void **value);
132 
147 #define ITABLE_ITERATE(table,key,value) itable_firstkey(table); while(itable_nextkey(table,&key,(void**)&value))
148 
149 #endif
itable_firstkey
void itable_firstkey(struct itable *h)
Begin iteration over all keys.
itable_delete
void itable_delete(struct itable *h)
Delete an integer table.
itable_clear
void itable_clear(struct itable *h, void(*delete_func)(void *))
Remove all entries from an integer table.
itable_lookup
void * itable_lookup(struct itable *h, UINT64_T key)
Look up a value by key.
itable_insert
int itable_insert(struct itable *h, UINT64_T key, const void *value)
Insert a key and value.
itable_create
struct itable * itable_create(int buckets)
Create a new integer table.
itable_size
int itable_size(struct itable *h)
Count the entries in an integer table.
itable_nextkey
int itable_nextkey(struct itable *h, UINT64_T *key, void **value)
Continue iteration over all keys.
itable_remove
void * itable_remove(struct itable *h, UINT64_T key)
Remove a value by key.
itable_pop
void * itable_pop(struct itable *h)
Remove any one value.