44 lines
1.4 KiB
C
44 lines
1.4 KiB
C
|
#ifndef VIETER_TREE_NODE
|
||
|
#define VIETER_TREE_NODE
|
||
|
|
||
|
#include "vieter_tree.h"
|
||
|
#include <stdint.h>
|
||
|
#include <stdbool.h>
|
||
|
|
||
|
#define VIETER_NODE_BLACK ((uint8_t)1)
|
||
|
|
||
|
typedef enum vieter_node_flag {
|
||
|
vieter_node_black = ((uint8_t)1) << 0
|
||
|
} vieter_node_flag;
|
||
|
|
||
|
typedef struct vieter_tree_node {
|
||
|
uint64_t key;
|
||
|
void *data;
|
||
|
struct vieter_tree_node *parent;
|
||
|
struct vieter_tree_node *left;
|
||
|
struct vieter_tree_node *right;
|
||
|
uint8_t flags;
|
||
|
} vieter_tree_node;
|
||
|
|
||
|
vieter_tree_node *vieter_tree_node_init();
|
||
|
|
||
|
void vieter_tree_node_free(vieter_tree_node *node);
|
||
|
|
||
|
vieter_tree_error vieter_tree_node_insert(vieter_tree_node *root, uint64_t key, void *data);
|
||
|
|
||
|
vieter_tree_error vieter_tree_node_search_node(vieter_tree_node **out, vieter_tree_node *root, uint64_t key);
|
||
|
vieter_tree_error vieter_tree_node_search(void **out, vieter_tree_node *root, uint64_t key);
|
||
|
|
||
|
vieter_tree_error vieter_tree_node_remove(void **out, vieter_tree_node *root, uint64_t key);
|
||
|
|
||
|
void vieter_tree_node_replace(vieter_tree_node *to_replace, vieter_tree_node *replacement);
|
||
|
|
||
|
void vieter_tree_node_set(vieter_tree_node *node, vieter_node_flag flag);
|
||
|
void vieter_tree_node_unset(vieter_tree_node *node, vieter_node_flag flag);
|
||
|
bool vieter_tree_node_get(vieter_tree_node *node, vieter_node_flag flag);
|
||
|
|
||
|
void vieter_tree_node_add_child(vieter_tree_node *parent, uint64_t key,
|
||
|
vieter_tree_node *child);
|
||
|
|
||
|
#endif
|