FDOSTUI
FreeDOS Text User Interface
hash.h
Go to the documentation of this file.
1 /*
2  HASH.H
3 
4  License CC0 PUBLIC DOMAIN
5 
6  To the extent possible under law, Mark J. Olesen has waived all copyright
7  and related or neighboring rights to FDOSTUI Library. This work is published
8  from: United States.
9 */
10 #ifndef __hash_h__
11 
12 #include <stddef.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 struct bucket
19 {
20  char * m_key;
21  void * m_value;
22  struct bucket * m_next;
23 };
24 
25 typedef void
27  void * io_value);
28 
29 struct hash
30 {
31  struct bucket ** m_bucket;
32  size_t m_slots;
34 };
35 
36 extern int
38  struct hash*const o_hash,
39  size_t const i_buckets,
40  hash_remove_cb i_remove);
41 
42 extern void
44  struct hash*const io_hash);
45 
46 extern int
48  struct hash*const io_hash,
49  char const * i_key,
50  void * i_value);
51 
52 extern void *
54  int *const o_found,
55  struct hash*const io_hash,
56  char const * i_key);
57 
58 extern int
60  struct hash*const io_hash,
61  char const * i_key);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #define __hash_h__
68 #endif
void(* hash_remove_cb)(void *io_value)
function prototype that is called to delete a value
Definition: hash.h:26
struct bucket ** m_bucket
Definition: hash.h:31
void hash_discharge(struct hash *const io_hash)
release resources held by the object
Definition: hash.c:196
size_t m_slots
Definition: hash.h:32
int hash_assign(struct hash *const o_hash, size_t const i_buckets, hash_remove_cb i_remove)
initialize hash object
Definition: hash.c:163
struct bucket * m_next
Definition: hash.h:22
int hash_remove(struct hash *const io_hash, char const *i_key)
remove a key fromt the hash table
Definition: hash.c:326
hash_remove_cb m_remove
Definition: hash.h:33
int hash_insert(struct hash *const io_hash, char const *i_key, void *i_value)
insert a key and value
Definition: hash.c:218
void * hash_lookup(int *const o_found, struct hash *const io_hash, char const *i_key)
lookup a value
Definition: hash.c:270
void * m_value
Definition: hash.h:21
char * m_key
Definition: hash.h:20
hash data structure that holds keys and values
Definition: hash.h:29
internal data structure that holds a single key and value
Definition: hash.h:18