Red-Black tree
[Containers]
These functions provide Red-Black trees management.
More...Data Structures | |
struct | _Eina_Rbtree |
Defines | |
#define | EINA_RBTREE Eina_Rbtree __rbtree |
recommended way to declare the inlined Eina_Rbtree in your type. | |
#define | EINA_RBTREE_GET(Rbtree) & ((Rbtree)->__rbtree) |
access the inlined node if it was created with EINA_RBTREE. | |
#define | EINA_RBTREE_CMP_NODE_CB(Function) ((Eina_Rbtree_Cmp_Node_Cb)Function) |
Cast using Eina_Rbtree_Cmp_Node_Cb. | |
#define | EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb)Function) |
Cast using Eina_Rbtree_Cmp_Key_Cb. | |
#define | EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function) |
Cast using Eina_Rbtree_Free_Cb. | |
Typedefs | |
typedef struct _Eina_Rbtree | Eina_Rbtree |
Type for a Red-Black tree node. | |
typedef Eina_Rbtree_Direction(* | Eina_Rbtree_Cmp_Node_Cb )(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data) |
Function used compare two nodes and see which direction to navigate. | |
typedef int(* | Eina_Rbtree_Cmp_Key_Cb )(const Eina_Rbtree *node, const void *key, int length, void *data) |
Function used compare node with a given key of specified length. | |
typedef void(* | Eina_Rbtree_Free_Cb )(Eina_Rbtree *node, void *data) |
Function used free a node. | |
Enumerations | |
enum | Eina_Rbtree_Color { EINA_RBTREE_RED, EINA_RBTREE_BLACK } |
node color. | |
enum | Eina_Rbtree_Direction { EINA_RBTREE_LEFT = 0, EINA_RBTREE_RIGHT = 1 } |
walk direction. | |
Functions | |
static Eina_Rbtree * | eina_rbtree_inline_lookup (const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) |
EAPI Eina_Rbtree * | eina_rbtree_inline_insert (Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2 |
EAPI Eina_Rbtree * | eina_rbtree_inline_remove (Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2 |
EAPI void | eina_rbtree_delete (Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data) EINA_ARG_NONNULL(2) |
EAPI Eina_Iterator * | eina_rbtree_iterator_prefix (const Eina_Rbtree *root) |
Returned a new prefix iterator associated to a rbtree. | |
EAPI Eina_Iterator * | eina_rbtree_iterator_infix (const Eina_Rbtree *root) |
Returned a new prefix iterator associated to a rbtree. | |
EAPI Eina_Iterator * | eina_rbtree_iterator_postfix (const Eina_Rbtree *root) |
Returned a new prefix iterator associated to a rbtree. | |
Variables | |
EAPI Eina_Rbtree * | EINA_WARN_UNUSED_RESULT |
Detailed Description
These functions provide Red-Black trees management.
Define Documentation
#define EINA_RBTREE Eina_Rbtree __rbtree |
recommended way to declare the inlined Eina_Rbtree in your type.
struct my_type { EINA_RBTREE; int my_value; char *my_name; };
- See also:
- EINA_RBTREE_GET()
Typedef Documentation
Type for a Red-Black tree node.
It should be inlined into user's type.
Function Documentation
EAPI Eina_Iterator * eina_rbtree_iterator_prefix | ( | const Eina_Rbtree * | root | ) |
Returned a new prefix iterator associated to a rbtree.
- Parameters:
-
root The root of rbtree.
- Returns:
- A new iterator.
root
. It will iterate the tree using prefix walk. If root
is NULL
, this function still returns a valid iterator that will always return false on eina_iterator_next(), thus keeping API sane.If the memory can not be allocated, NULL is returned and EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is returned.
- Warning:
- if the rbtree structure changes then the iterator becomes invalid! That is, if you add or remove nodes this iterator behavior is undefined and your program may crash!
EAPI Eina_Iterator * eina_rbtree_iterator_infix | ( | const Eina_Rbtree * | root | ) |
Returned a new prefix iterator associated to a rbtree.
- Parameters:
-
root The root of rbtree.
- Returns:
- A new iterator.
root
. It will iterate the tree using infix walk. If root
is NULL
, this function still returns a valid iterator that will always return false on eina_iterator_next(), thus keeping API sane.If the memory can not be allocated, NULL is returned and EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is returned.
- Warning:
- if the rbtree structure changes then the iterator becomes invalid! That is, if you add or remove nodes this iterator behavior is undefined and your program may crash!
EAPI Eina_Iterator * eina_rbtree_iterator_postfix | ( | const Eina_Rbtree * | root | ) |
Returned a new prefix iterator associated to a rbtree.
- Parameters:
-
root The root of rbtree.
- Returns:
- A new iterator.
root
. It will iterate the tree using postfix walk. If root
is NULL
, this function still returns a valid iterator that will always return false on eina_iterator_next(), thus keeping API sane.If the memory can not be allocated, NULL is returned and EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is returned.
- Warning:
- if the rbtree structure changes then the iterator becomes invalid! That is, if you add or remove nodes this iterator behavior is undefined and your program may crash!