data_structures
|
Go to the source code of this file.
Data Structures | |
struct | s_rbt_node |
A node in a red-black tree. More... | |
struct | s_rbt |
A left-leaning red-black binary search tree. More... | |
Typedefs | |
typedef enum e_rbt_node_color | t_rbt_node_color |
typedef struct s_rbt_node | t_rbt_node |
typedef struct s_rbt | t_rbt |
Enumerations | |
enum | e_rbt_node_color { RBT_RED, RBT_BLACK } |
The color of a node in a red-black tree. More... | |
Functions | |
t_rbt * | rbt_new (const t_type *key_type, const t_type *val_type) |
Initializes a new empty tree. More... | |
void | rbt_put (t_rbt *rbt, const void *key, const void *val) |
Adds a new item to the tree or overwrites an existing one. More... | |
void * | rbt_get (const t_rbt *rbt, const void *key) |
Returns the value associated with a specified key. More... | |
size_t | rbt_size (const t_rbt *rbt) |
Returns the number of elements in this tree. More... | |
void | rbt_delete (t_rbt *rbt) |
Deletes this tree and free all its items and the associated data. More... | |
size_t | rbt_height (const t_rbt *rbt) |
Returns the number of tiers in the tree. More... | |
void * | rbt_min (const t_rbt *rbt) |
Returns the smallest key in the tree. More... | |
void * | rbt_max (const t_rbt *rbt) |
Returns the largest key in the tree. More... | |
void * | rbt_floor (const t_rbt *rbt, const void *key) |
Returns the largest key less than or equal to the specified key. More... | |
void * | rbt_ceil (const t_rbt *rbt, const void *key) |
Returns the smallest key greater than or equal to the specified key. More... | |
size_t | rbt_rank (const t_rbt *rbt, const void *key) |
Returns the number of keys in the tree strictly less than the specified key. More... | |
t_queue * | rbt_keys (const t_rbt *rbt) |
Returns a queue with all the keys in the tree, sorted in the ascending order. More... | |
t_queue * | rbt_vals (const t_rbt *rbt) |
Returns a queue with all the value in the tree, sorted by the associated keys in the ascending order. More... | |
int | rbt_contains (const t_rbt *rbt, const void *key) |
Does the tree contain the specified key? More... | |
void * | rbt_nth (const t_rbt *rbt, size_t n) |
Returns the key of the nth element in the tree. More... | |
enum e_rbt_node_color |
void* rbt_ceil | ( | const t_rbt * | rbt, |
const void * | key | ||
) |
Returns the smallest key greater than or equal to the specified key.
key | The key |
NULL
, if the tree is empty. Definition at line 33 of file rbt_ceil.c.
int rbt_contains | ( | const t_rbt * | rbt, |
const void * | key | ||
) |
Does the tree contain the specified key?
key | The key |
1
if tree contains the specified key, 0
otherwise Definition at line 16 of file rbt_contains.c.
void rbt_delete | ( | t_rbt * | rbt | ) |
Deletes this tree and free all its items and the associated data.
Does nothing if the argument is NULL
.
Definition at line 34 of file rbt_delete.c.
void* rbt_floor | ( | const t_rbt * | rbt, |
const void * | key | ||
) |
Returns the largest key less than or equal to the specified key.
key | The key |
NULL
, if the tree is empty. Definition at line 33 of file rbt_floor.c.
void* rbt_get | ( | const t_rbt * | rbt, |
const void * | key | ||
) |
size_t rbt_height | ( | const t_rbt * | rbt | ) |
Returns the number of tiers in the tree.
Definition at line 28 of file rbt_height.c.
Returns a queue with all the keys in the tree, sorted in the ascending order.
Definition at line 26 of file rbt_keys.c.
void* rbt_max | ( | const t_rbt * | rbt | ) |
void* rbt_min | ( | const t_rbt * | rbt | ) |
Initializes a new empty tree.
key_type | The type of keys |
val_type | The type of values |
NULL
on failure. In case of an error, errno
is set accordingly. cmp
function). void* rbt_nth | ( | const t_rbt * | rbt, |
size_t | n | ||
) |
void rbt_put | ( | t_rbt * | rbt, |
const void * | key, | ||
const void * | val | ||
) |
size_t rbt_rank | ( | const t_rbt * | rbt, |
const void * | key | ||
) |
Returns the number of keys in the tree strictly less than the specified key.
key | The key |
Definition at line 34 of file rbt_rank.c.
size_t rbt_size | ( | const t_rbt * | rbt | ) |
Returns the number of elements in this tree.
Definition at line 17 of file rbt_size.c.
Returns a queue with all the value in the tree, sorted by the associated keys in the ascending order.
Definition at line 26 of file rbt_vals.c.