-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash.h
52 lines (41 loc) · 1.24 KB
/
hash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Copyright 2001, 2002, 2003 David Mansfield and Cobite, Inc.
* See COPYING file for license information
*/
#ifndef _COMMON_HASH_H
#define _COMMON_HASH_H
#include "list.h"
struct hash_entry
{
char *he_key;
void *he_obj;
struct list_head he_list;
};
struct hash_table
{
int ht_size;
struct list_head *ht_lists;
int iterator;
struct list_head *iterator_ptr;
};
enum
{
HT_NO_KEYCOPY,
HT_KEYCOPY
};
#ifdef __cplusplus
extern "C" {
#endif
struct hash_table *create_hash_table(unsigned int sz);
void destroy_hash_table(struct hash_table *tbl, void (*delete_obj)(void *));
void *put_hash_object(struct hash_table *tbl, const char *key, void *obj);
void *get_hash_object(struct hash_table *tbl, const char *key);
void *remove_hash_object(struct hash_table *tbl, const char *key);
int put_hash_object_ex(struct hash_table *tbl, const char *key, void *obj, int, char **, void **);
void destroy_hash_table_ex(struct hash_table *tbl, void (*delete_entry)(const void *, char *, void *), const void *);
void reset_hash_iterator(struct hash_table *tbl);
struct hash_entry *next_hash_entry(struct hash_table *tbl);
#ifdef __cplusplus
}
#endif
#endif /* _COMMON_HASH_H */