-
Notifications
You must be signed in to change notification settings - Fork 23
/
hash.h
44 lines (35 loc) · 1.05 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
#ifndef HASH_H_
#define HASH_H_
#include <stdint.h>
#include <map>
#include "list.h"
typedef struct {
char *name;
} store_t;
struct comparator
: public std::binary_function<const char *, const char *, bool>
{
bool operator()(const char * _Left, const char *_Right) const
{
if (strcmp(_Left, _Right) < 0)
return true;
else
return false;
}
};
typedef std::map<const char *, void *, comparator> htt_base;
class hash_t : public htt_base {
public:
void (*remove_callback)(void *);
hash_t(void (*remove_callback)(void *));
};
typedef void (*HASH_ENUM_CALLBACK)(void *, void *);
typedef void (*HASH_REMOVE_CALLBACK)(void *);
hash_t *hash_init (void remove_callback(void *));
void hash_insert (hash_t *ht, void *store);
void *hash_lookup (hash_t *ht, const char *name);
int hash_remove (hash_t *ht, const char *name);
void hash_enum (hash_t *ht, void enum_callback(void *, void *), void *arg);
int hash_count (hash_t *ht);
void hash_free (hash_t *ht);
#endif /*HASH_H_*/