libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
tree.h
Go to the documentation of this file.
1
5#ifndef LIBCLOD_TREE_H
6#define LIBCLOD_TREE_H
7
8#include <clod/lib.h>
9
10#include "clod/memory.h"
11
23struct clod_tree {
26
28 unsigned char key_size;
29
31 unsigned char val_size;
32
35
37 unsigned short node_size;
38
41
43 int (*compare)(const void *key1, const void *key2, void *user);
44
48};
49
55CLOD_API CLOD_NONNULL(1)
56bool clod_tree_create(struct clod_tree *tree);
57
62CLOD_API CLOD_NONNULL(1)
63void clod_tree_destroy(struct clod_tree *tree);
64
77CLOD_API CLOD_NONNULL(1, 2, 3)
78bool clod_tree_add(const struct clod_tree *tree, const void *key, const void *val, void *key_out, void *val_out);
79
89CLOD_API CLOD_NONNULL(1, 2)
90bool clod_tree_get(const struct clod_tree *tree, const void *key, void *key_out, void *val_out);
91
101CLOD_API CLOD_NONNULL(1, 2)
102bool clod_tree_del(const struct clod_tree *tree, const void *key, void *key_out, void *val_out);
103
110 struct clod_tree_node *node;
111 const void *key;
112 void *val;
113};
114
124CLOD_API CLOD_NONNULL(1, 2, 3)
125bool clod_tree_find(struct clod_tree *tree, struct clod_tree_location *location, const void *key);
126
134CLOD_API CLOD_NONNULL(1, 2)
135bool clod_tree_next(struct clod_tree *tree, struct clod_tree_location *location);
136
144CLOD_API CLOD_NONNULL(1, 2)
145bool clod_tree_prev(struct clod_tree *tree, struct clod_tree_location *location);
146
147#endif
Memory allocation methods.
Allocator.
Definition memory.h:16
int(* compare)(const void *key1, const void *key2, void *user)
Comparison function.
Definition tree.h:43
unsigned char val_size
Size of values in the tree.
Definition tree.h:31
unsigned short node_size
Size of each node in the tree.
Definition tree.h:37
void * compare_user
User variable passed to invocations of compare.
Definition tree.h:40
bool disable_checksum
Disables the checksum used to validate each node.
Definition tree.h:34
unsigned char key_size
Size of keys in the tree.
Definition tree.h:28
struct clod_tree_node * root
Pointer to the root node.
Definition tree.h:25
clod_allocator allocator
Definition tree.h:47
bool clod_tree_find(struct clod_tree *tree, struct clod_tree_location *location, const void *key)
bool clod_tree_create(struct clod_tree *tree)
Definition tree.c:521
bool clod_tree_del(const struct clod_tree *tree, const void *key, void *key_out, void *val_out)
Definition tree.c:734
void clod_tree_destroy(struct clod_tree *tree)
Definition tree.c:559
bool clod_tree_prev(struct clod_tree *tree, struct clod_tree_location *location)
bool clod_tree_next(struct clod_tree *tree, struct clod_tree_location *location)
bool clod_tree_get(const struct clod_tree *tree, const void *key, void *key_out, void *val_out)
Definition tree.c:718
bool clod_tree_add(const struct clod_tree *tree, const void *key, const void *val, void *key_out, void *val_out)
Definition tree.c:586