diff options
author | Marvin Borner | 2023-05-26 20:34:07 +0200 |
---|---|---|
committer | Marvin Borner | 2023-05-26 20:34:22 +0200 |
commit | 896e0e1bd8502a6d7f901f9e13bcd95df5d98635 (patch) | |
tree | 4bc1916e81f75980c213802b1d4f3e81f74fb3b3 /inc/lib/hashmap.h | |
parent | 464cca35825a02541efd46cfd3af91146c118d01 (diff) |
Abstract abstractification
Diffstat (limited to 'inc/lib/hashmap.h')
-rw-r--r-- | inc/lib/hashmap.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/inc/lib/hashmap.h b/inc/lib/hashmap.h new file mode 100644 index 0000000..809ddca --- /dev/null +++ b/inc/lib/hashmap.h @@ -0,0 +1,31 @@ +// Copyright 2020 Joshua J Baker. All rights reserved. +// Copyright 2023 Marvin Borner +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file. + +#ifndef CALM_HASHMAP_H +#define CALM_HASHMAP_H + +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +struct hashmap; + +struct hashmap *hashmap_new(size_t elsize, size_t cap, + void (*elfree)(void *item)); + +void hashmap_free(struct hashmap *map); +void hashmap_clear(struct hashmap *map, bool update_cap); +size_t hashmap_count(struct hashmap *map); +bool hashmap_oom(struct hashmap *map); +void *hashmap_probe(struct hashmap *map, uint64_t position); +bool hashmap_scan(struct hashmap *map, bool (*iter)(void *item)); +bool hashmap_iter(struct hashmap *map, size_t *i, void **item); + +void *hashmap_get(struct hashmap *map, uint64_t hash); +void *hashmap_delete(struct hashmap *map, uint64_t hash); +void *hashmap_set(struct hashmap *map, void *item, uint64_t hash); +void hashmap_set_grow_by_power(struct hashmap *map, size_t power); + +#endif |