Rabbit Tree
Radix bit tries for implementing associative arrays and sets in C.
|
#include <limits.h>
Go to the source code of this file.
Macros | |
#define | _RBT_TOKEN_2(a, b) _ ## a ## b |
Identical to RBT_TOKEN_2() except that the resulting token is prefixed with an underscore. More... | |
#define | _RBT_TOKEN_2_W(a, b) _RBT_TOKEN_2(a,b) |
A wrapper for _RBT_TOKEN_2() to ensure macro expansion. More... | |
#define | BITS_PER_BYTE CHAR_BIT |
The number of bits in a byte. | |
#define | BYTE_T char |
A byte type. | |
#define | DIV_UP(x, y) ((x) ? (1 + (x-1)/y) : 0) |
Ceiling division of a positive integer. More... | |
#define | FIRST_BIT_IS_1(x) (MOST_SIGNIFICANT_BIT(typeof(x)) & (x)) |
Determine if the most significant bit is 1. More... | |
#define | MAX(a, b) (((a) > (b)) ? (a) : (b)) |
Return the maximum of a or b . More... | |
#define | MIN(a, b) (((a) < (b)) ? (a) : (b)) |
Return the minimum of a or b . More... | |
#define | MOST_SIGNIFICANT_BIT(x) (((x) ~ 0) ^ (((x) ~ 0) >> 1)) |
The most significant bit of the given integer's type. More... | |
#define | MOST_SIGNIFICANT_BIT_W(x) MOST_SIGNIFICANT_BIT(x) |
A wrapper for MOST_SIGNIFICANT_BIT() to ensure macro expansion. More... | |
#define | N_BIT_IS_1(x, n) (MOST_SIGNIFICANT_BIT(typeof(x)) & (x << n)) |
Determine if the nth bit is 1. More... | |
#define | RBT_TOKEN_2(a, b) a ## b |
Combine a and b into a single token. More... | |
#define | RBT_TOKEN_2_W(a, b) RBT_TOKEN_2(a,b) |
A wrapper for RBT_TOKEN_2() to ensure macro expansion. More... | |
Enumerations | |
enum | rbt_query_action_t { RBT_QUERY_ACTION_DELETE , RBT_QUERY_ACTION_INSERT , RBT_QUERY_ACTION_RETRIEVE , RBT_QUERY_ACTION_RETRIEVE_AND_INSERT , RBT_QUERY_ACTION_SWAP } |
Query action for RBT_NODE_QUERY() . More... | |
enum | rbt_retrieve_action_t { RBT_RETRIEVE_ACTION_NOTHING , RBT_RETRIEVE_ACTION_INSERT , RBT_RETRIEVE_ACTION_INSERT_OR_REPLACE , RBT_RETRIEVE_ACTION_PREFIX_SUBTREE } |
Retrieval action for RBT_NODE_RETRIEVE() . More... | |
Functions | |
const char * | rbt_query_action_string (rbt_query_action_t action) |
Return a string representing a query action. More... | |
const char * | rbt_retrieve_action_string (rbt_retrieve_action_t action) |
Return a string representing a retrieval action. More... | |
#define _RBT_TOKEN_2 | ( | a, | |
b | |||
) | _ ## a ## b |
Identical to RBT_TOKEN_2()
except that the resulting token is prefixed with an underscore.
[in] | a | The first part. |
[in] | b | The second part. |
#define _RBT_TOKEN_2_W | ( | a, | |
b | |||
) | _RBT_TOKEN_2(a,b) |
A wrapper for _RBT_TOKEN_2()
to ensure macro expansion.
[in] | a | The first part. This may be a macro. |
[in] | b | The second part. This may be a macro. |
#define DIV_UP | ( | x, | |
y | |||
) | ((x) ? (1 + (x-1)/y) : 0) |
Ceiling division of a positive integer.
Divide dividend by divisor, rounding any remainder up. This catches overflows.
[in] | x | The dividend. |
[in] | y | The divisor. |
#define FIRST_BIT_IS_1 | ( | x | ) | (MOST_SIGNIFICANT_BIT(typeof(x)) & (x)) |
Determine if the most significant bit is 1.
[in] | x | The number containing the bit to check. |
#define MAX | ( | a, | |
b | |||
) | (((a) > (b)) ? (a) : (b)) |
Return the maximum of a
or b
.
[in] | a | The first number. |
[in] | b | The second number. |
#define MIN | ( | a, | |
b | |||
) | (((a) < (b)) ? (a) : (b)) |
Return the minimum of a
or b
.
[in] | a | The first number. |
[in] | b | The second number. |
#define MOST_SIGNIFICANT_BIT | ( | x | ) | (((x) ~ 0) ^ (((x) ~ 0) >> 1)) |
The most significant bit of the given integer's type.
[in] | x | The number to check. |
#define MOST_SIGNIFICANT_BIT_W | ( | x | ) | MOST_SIGNIFICANT_BIT(x) |
A wrapper for MOST_SIGNIFICANT_BIT()
to ensure macro expansion.
[in] | x | The number to check. |
#define N_BIT_IS_1 | ( | x, | |
n | |||
) | (MOST_SIGNIFICANT_BIT(typeof(x)) & (x << n)) |
Determine if the nth bit is 1.
[in] | x | The number containing the bit to check. |
[in] | n | The number of the bit to check. |
#define RBT_TOKEN_2 | ( | a, | |
b | |||
) | a ## b |
Combine a
and b
into a single token.
[in] | a | The first part. |
[in] | b | The second part. |
#define RBT_TOKEN_2_W | ( | a, | |
b | |||
) | RBT_TOKEN_2(a,b) |
A wrapper for RBT_TOKEN_2()
to ensure macro expansion.
[in] | a | The first part. This may be a macro. |
[in] | b | The second part. This may be a macro. |
enum rbt_query_action_t |
Query action for RBT_NODE_QUERY()
.
Retrieval action for RBT_NODE_RETRIEVE()
.
Enumerator | |
---|---|
RBT_RETRIEVE_ACTION_NOTHING | No additional action is performed. |
RBT_RETRIEVE_ACTION_INSERT | An insertion is made if the target node does not exist. Existing values are not modified. |
RBT_RETRIEVE_ACTION_INSERT_OR_REPLACE | An insertion is made if the target node does not exist. Existing values are modified. |
RBT_RETRIEVE_ACTION_PREFIX_SUBTREE | There are three possibilities when matching a prefix. 1) No node contains the prefix. 2) One node's associated key is equal to the prefix. All children of this node also contain the prefix in their associated keys. 3) One node's associated key is the first to contain the prefix. All children of this node also contain the prefix in their associated keys. Case 1 returns NULL without ambiguity. For cases 2 and 3, information about the eventual key difference is required. This can be retrieved by updating the bits field of the passed parent_node_ptr in the retrieve function.
|
const char * rbt_query_action_string | ( | rbt_query_action_t | action | ) |
Return a string representing a query action.
[in] | action | The action for which to return a string. |
const char * rbt_retrieve_action_string | ( | rbt_retrieve_action_t | action | ) |
Return a string representing a retrieval action.
[in] | action | The action for which to return a string. |