My Kernel
v0.1.0
hashtable.h
Go to the documentation of this file.
1
19
#ifndef LIBALGO_HASHTABLE_H
20
#define LIBALGO_HASHTABLE_H
21
22
#include <
libalgo/linked_list.h
>
23
27
struct
hashtable_entry
{
28
void
*
key
;
29
struct
linked_list_node
this
;
30
};
31
32
#define hashtable_fields size_t size;
33
37
struct
hashtable {
38
hashtable_fields;
39
llist_t
buckets[];
40
};
41
43
#define DECLARE_HASHTABLE(name, size) \
44
union { \
45
struct hashtable table; \
46
struct { \
47
hashtable_fields; \
48
llist_t buckets[size]; \
49
}; \
50
} name
51
52
void
__hashtable_init(
struct
hashtable *,
size_t
hashtable_size);
53
void
__hashtable_insert(
struct
hashtable *,
struct
hashtable_entry
*);
54
struct
hashtable_entry
*__hashtable_remove(
struct
hashtable *,
const
void
*
key
);
55
struct
hashtable_entry
*__hashtable_find(
struct
hashtable *,
const
void
*
key
);
56
62
#define hashtable_init(hashtable) \
63
__hashtable_init(&(hashtable)->table, ARRAY_SIZE((hashtable)->buckets))
64
71
#define hashtable_insert(hashtable, entry) \
72
__hashtable_insert(&(hashtable)->table, entry)
73
81
#define hashtable_remove(hashtable, key) \
82
__hashtable_remove(&(hashtable)->table, key)
83
91
#define hashtable_find(hashtable, key) \
92
__hashtable_find(&(hashtable)->table, key)
93
94
#endif
/* LIBALGO_HASHTABLE_H */
95
linked_list.h
hashtable_entry
Structure used to store entries inside an hashtable.
Definition:
hashtable.h:27
hashtable_entry::key
void * key
Definition:
hashtable.h:28
hashtable_entry::this
struct linked_list_node this
Definition:
hashtable.h:29
linked_list_head
The head of a doubly linked list.
Definition:
linked_list.h:43
linked_list_node
Intrusive doubly-linked list node.
Definition:
linked_list.h:27
lib
libalgo
include
libalgo
hashtable.h
Generated by
1.9.5