#include <clod/lib.h>
#include "clod/memory.h"
Go to the source code of this file.
|
| bool | clod_tree_create (struct clod_tree *tree) |
| void | clod_tree_destroy (struct clod_tree *tree) |
| bool | clod_tree_add (const struct clod_tree *tree, const void *key, const void *val, void *key_out, void *val_out) |
| bool | clod_tree_get (const struct clod_tree *tree, const void *key, void *key_out, void *val_out) |
| bool | clod_tree_del (const struct clod_tree *tree, const void *key, void *key_out, void *val_out) |
| bool | clod_tree_find (struct clod_tree *tree, struct clod_tree_location *location, const void *key) |
| bool | clod_tree_next (struct clod_tree *tree, struct clod_tree_location *location) |
| bool | clod_tree_prev (struct clod_tree *tree, struct clod_tree_location *location) |
◆ clod_tree_create()
| bool clod_tree_create |
( |
struct clod_tree * | tree | ) |
|
Initialise a tree.
- Parameters
-
| [in] | Tree | Tree to initialise. |
- Returns
- True on success, false if parameters failed validation.
Definition at line 521 of file tree.c.
◆ clod_tree_destroy()
| void clod_tree_destroy |
( |
struct clod_tree * | tree | ) |
|
Destroy a tree. All nodes are freed.
- Parameters
-
Definition at line 559 of file tree.c.
◆ clod_tree_add()
| bool clod_tree_add |
( |
const struct clod_tree * | tree, |
|
|
const void * | key, |
|
|
const void * | val, |
|
|
void * | key_out, |
|
|
void * | val_out ) |
Add a key/value pair to the tree. If the key compares equal to an existing key, the operation fails, optionally returning the existing key and value.
- Parameters
-
| [in] | Tree | Tree to add the key/value pair to. |
| [in] | key | Pointer to a key of the configured size. |
| [in] | val | Pointer to a value of the configured size. |
| [out] | key_out | (nullable) Where the existing key is written to if the key already exists. |
| [out] | val_out | (nullable) Where the existing value is written to if the key already exists. |
- Returns
- True on success. False otherwise.
Definition at line 586 of file tree.c.
◆ clod_tree_get()
| bool clod_tree_get |
( |
const struct clod_tree * | tree, |
|
|
const void * | key, |
|
|
void * | key_out, |
|
|
void * | val_out ) |
Get a key/value pair from the tree.
- Parameters
-
| [in] | Tree | Tree to get the key/value from. |
| [in] | key | Pointer to a key of the configured size. |
| [out] | key_out | (nullable) Where the existing key is written to if the key already exists. |
| [out] | val_out | (nullable) Where the existing value is written to if the key already exists. |
- Returns
- True if the given key was found. False otherwise.
Definition at line 718 of file tree.c.
◆ clod_tree_del()
| bool clod_tree_del |
( |
const struct clod_tree * | tree, |
|
|
const void * | key, |
|
|
void * | key_out, |
|
|
void * | val_out ) |
Remove a key/value pair from the tree.
- Parameters
-
| [in] | Tree | Tree to remove the key/value pair from. |
| [in] | key | Pointer to a key of the configured size. |
| [out] | key_out | (nullable) Where the existing key is written to if the key already exists. |
| [out] | val_out | (nullable) Where the existing value is written to if the key already exists. |
- Returns
- True if the given key was successfully found and removed. False otherwise.
Definition at line 734 of file tree.c.
◆ clod_tree_find()
Find the element equal to, or the next lower element from, the provided key. If an exact match is found, the method returns true.
- Parameters
-
| [in] | Tree | Tree to search in. |
| [out] | location | Location of the search result. |
| [in] | key | Pointer to a key of the configured size. |
- Returns
- True if an exact match was found. False otherwise.
◆ clod_tree_next()
Get the next element in the tree.
- Parameters
-
| [in] | Tree | Tree to get next element in. |
| [in,out] | location | Location of the current element. If the location is not initialised (null node member), the first element in the tree is returned. |
- Returns
- True if the next element existed. False otherwise.
◆ clod_tree_prev()
Get the previous element in the tree.
- Parameters
-
| [in] | Tree | Tree to get the previous element from. |
| [in,out] | location | Location of the current element. If the location is not initialised (null node member), the last element in the tree is returned. |
- Returns
- True if the next element existed. False otherwise.