libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
table.h
1
17#ifndef LIBCLOD_TABLE_H
18#define LIBCLOD_TABLE_H
19
20#include <clod/lib.h>
21#include <stddef.h>
22#include <stdint.h>
23
28struct clod_table;
29
41 uint64_t (*hash_func)(uint64_t seed, const void *key, size_t key_size, void *user);
46 int (*cmp_func)(const void *key1, size_t key1_size, const void *key2, size_t key2_size, void *user);
48 void *(*malloc_func)(size_t, void *user);
50 void (*free_func)(void*, void *user);
52 void *user;
53};
54
60CLOD_API CLOD_USE_RETURN
61struct clod_table *
62clod_table_create(const struct clod_table_opts *opts);
63
68CLOD_API CLOD_NONNULL(1)
69void
71
77CLOD_API CLOD_PURE CLOD_NONNULL(1)
78size_t
79clod_table_len(const struct clod_table *t);
80
93CLOD_API CLOD_NONNULL(1, 2)
94bool
95clod_table_add(struct clod_table *t, const void *element, size_t key_size, void **existing_out);
96
109CLOD_API CLOD_NONNULL(1, 2, 4)
110bool
111clod_table_set(struct clod_table *t, const void *element, size_t key_size, void **existing_out);
112
120CLOD_API CLOD_PURE CLOD_NONNULL(1, 2)
121void *
122clod_table_get(const struct clod_table *t, const void *key, size_t key_size);
123
132CLOD_API CLOD_USE_RETURN CLOD_NONNULL(1, 2)
133void *
134clod_table_del(struct clod_table *t, const void *key, size_t key_size);
135
137 void *element;
138 size_t key_size;
139 size_t _internal;
140};
141#define CLOD_TABLE_ITER_INIT (struct clod_table_iter){ ._internal = 0 }
142
155CLOD_API CLOD_NONNULL(1, 2)
156bool
157clod_table_iter(const struct clod_table *t, struct clod_table_iter *iter);
158
163CLOD_API
164uint64_t
165clod_table_hash_ptr(uint64_t seed, const void *key, size_t key_size, void *user);
166
171CLOD_API
172int
173clod_table_cmp_ptr(const void *key1, size_t key1_size, const void *key2, size_t key2_size, void *user);
174
176#endif
int clod_table_cmp_ptr(const void *key1, size_t key1_size, const void *key2, size_t key2_size, void *user)
Definition table.c:177
size_t clod_table_len(const struct clod_table *t)
Definition table.c:209
void clod_table_destroy(struct clod_table *t)
Definition table.c:205
bool clod_table_set(struct clod_table *t, const void *element, size_t key_size, void **existing_out)
Definition table.c:224
uint64_t clod_table_hash_ptr(uint64_t seed, const void *key, size_t key_size, void *user)
Definition table.c:172
struct clod_table * clod_table_create(const struct clod_table_opts *opts)
Definition table.c:190
bool clod_table_add(struct clod_table *t, const void *element, size_t key_size, void **existing_out)
Definition table.c:212
void * clod_table_get(const struct clod_table *t, const void *key, size_t key_size)
Definition table.c:236
void * clod_table_del(struct clod_table *t, const void *key, size_t key_size)
Definition table.c:245
void * user
Definition table.h:52
size_t min_capacity
Definition table.h:37
int(* cmp_func)(const void *key1, size_t key1_size, const void *key2, size_t key2_size, void *user)
Definition table.h:46
uint64_t(* hash_func)(uint64_t seed, const void *key, size_t key_size, void *user)
Definition table.h:41
void(* free_func)(void *, void *user)
Definition table.h:50