| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #ifndef TOOLBOX_HASHTABLE_H
- #define TOOLBOX_HASHTABLE_H
- #include "toolbox/errno.h"
- #include <stddef.h>
- #include <stdint.h>
- #ifndef HASHTABLE_SIZE_BYTES
- #define HASHTABLE_SIZE_BYTES (1024*1024)
- #endif
- #ifdef TOOLBOX_TYPEDEF
- typedef struct hashtable hashtable_st;
- #endif
- struct hashtable;
- __attribute__((__pure__))
- struct hashtable *
- hashtable_create(void);
- RET_TYPE
- hashtable_destroy(struct hashtable **self);
- __attribute__((__pure__))
- _Bool
- hashtable_contain_item(const struct hashtable *self
- , const void* item, const size_t item_size);
- __attribute__((__pure__))
- _Bool
- hashtable_contain_key(const struct hashtable *self
- , const char *key);
- __attribute__((__pure__))
- _Bool
- hashtable_contain_key_hash(const struct hashtable *self
- , const size_t key_hash);
- __attribute__((__pure__))
- const void *
- hashtable_get(const struct hashtable *self
- , const char *key);
- __attribute__((__pure__))
- const void *
- hashtable_get_or_default(const struct hashtable *self
- , const char *key
- , const void *default_item);
- __attribute__((__pure__))
- _Bool
- hashtable_is_empty(const struct hashtable *self);
- RET_TYPE
- hashtable_put(struct hashtable *self
- , const char *key
- , const void *item, const size_t item_size);
- const void *
- hashtable_remove(struct hashtable *self, const char *key);
- _Bool
- hashtable_remove_if_equal(struct hashtable *self
- , const char *key
- , const void *item, const size_t item_size);
- const void *
- hashtable_replace(struct hashtable *self
- , const char *key
- , const void *item, const size_t item_size);
- _Bool
- hashtable_replace_if_equal(struct hashtable *self
- , const char *key
- , const void *restrict old_item
- , const size_t item_old_size
- , const void *restrict new_item
- , const size_t item_new_size);
- size_t
- hashtable_used_size(const struct hashtable *self);
- RET_TYPE
- hashtable_for_each(struct hashtable *self
- , void (*for_each)(void *item, size_t *item_size));
- #endif
|