| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #ifndef TOOLBOX_HASHTABLE_H
- #define TOOLBOX_HASHTABLE_H
- #include "toolbox/return_codes.h"
- #include <stdbool.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
|