2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
8 #include "fssh_types.h"
13 // can be allocated on the stack
14 typedef struct hash_iterator
{
19 typedef struct hash_table hash_table
;
21 struct hash_table
*hash_init(uint32_t table_size
, int next_ptr_offset
,
22 int compare_func(void *element
, const void *key
),
23 uint32_t hash_func(void *element
, const void *key
, uint32_t range
));
24 int hash_uninit(struct hash_table
*table
);
25 fssh_status_t
hash_insert(struct hash_table
*table
, void *_element
);
26 fssh_status_t
hash_remove(struct hash_table
*table
, void *_element
);
27 void hash_remove_current(struct hash_table
*table
, struct hash_iterator
*iterator
);
28 void *hash_remove_first(struct hash_table
*table
, uint32_t *_cookie
);
29 void *hash_find(struct hash_table
*table
, void *e
);
30 void *hash_lookup(struct hash_table
*table
, const void *key
);
31 struct hash_iterator
*hash_open(struct hash_table
*table
, struct hash_iterator
*i
);
32 void hash_close(struct hash_table
*table
, struct hash_iterator
*i
, bool free_iterator
);
33 void *hash_next(struct hash_table
*table
, struct hash_iterator
*i
);
34 void hash_rewind(struct hash_table
*table
, struct hash_iterator
*i
);
36 /* function pointers must look like this:
38 * uint32 hash_func(void *e, const void *key, uint32 range);
39 * hash function should calculate hash on either e or key,
40 * depending on which one is not NULL - they also need
41 * to make sure the returned value is within range.
42 * int compare_func(void *e, const void *key);
43 * compare function should compare the element with
44 * the key, returning 0 if equal, other if not
47 uint32_t hash_hash_string(const char *str
);
49 } // namespace FSShell
51 #endif /* _FSSH_HASH_H */