Red-black trees.
More...
#include <stdint.h>
#include <stddef.h>
Go to the source code of this file.
|
#define | rbtree_item(ptr, type, member) ((type*)(((char*)ptr) - offsetof(type, member))) |
| Retrieves an rbtree item.
|
|
◆ __attribute__()
__attribute__ |
( |
(warn_unused_result) |
| ) |
|
◆ rbtree_clear()
Clears an rbtree.
- Parameters
-
tree | Pointer to the tree. |
destructor | Destructor to use when clearing the tree's nodes. |
◆ rbtree_empty()
int rbtree_empty |
( |
const rbtree_t * |
tree | ) |
|
Gets whether an rbtree is empty.
- Parameters
-
- Returns
- A non-zero value if the tree is not empty.
◆ rbtree_find()
rbtree_node_t* rbtree_find |
( |
const rbtree_t * |
tree, |
|
|
const rbtree_node_t * |
node |
|
) |
| |
Finds a node within an rbtree.
- Parameters
-
tree | Pointer to the tree. |
node | Pointer to the node. |
- Returns
- The located node.
◆ rbtree_init()
Initializes an rbtree.
- Parameters
-
tree | Pointer to the tree. |
comparator | Comparator to use. |
◆ rbtree_insert_multi()
void rbtree_insert_multi |
( |
rbtree_t * |
tree, |
|
|
rbtree_node_t * |
node |
|
) |
| |
Inserts multiple nodes into an rbtree.
- Parameters
-
tree | Pointer to the tree. |
node | Pointer to the nodes. |
◆ rbtree_max()
rbtree_node_t* rbtree_max |
( |
const rbtree_t * |
tree | ) |
|
Gets the maximum node of an rbtree.
- Parameters
-
- Returns
- The maximum node.
◆ rbtree_min()
rbtree_node_t* rbtree_min |
( |
const rbtree_t * |
tree | ) |
|
Gets the minimum node of an rbtree.
- Parameters
-
- Returns
- The minimum node.
◆ rbtree_node_next()
rbtree_node_t* rbtree_node_next |
( |
const rbtree_node_t * |
node | ) |
|
Gets the next node from an rbtree node.
- Parameters
-
- Returns
- The next node.
◆ rbtree_node_prev()
rbtree_node_t* rbtree_node_prev |
( |
const rbtree_node_t * |
node | ) |
|
Gets the previous node from an rbtree node.
- Parameters
-
- Returns
- The previous node.
◆ rbtree_remove()
Removes a node from an rbtree.
- Parameters
-
tree | Pointer to the tree. |
node | Pointer to the node. |
destructor | Destructor to use when removing the node. |
- Returns
- The removed node.
◆ rbtree_size()
size_t rbtree_size |
( |
const rbtree_t * |
tree | ) |
|
Gets the size of an rbtree.
- Parameters
-