Rabbit Tree
Radix bit tries for implementing associative arrays and sets in C.
wrapper.h File Reference
#include "common.h"
#include "debug.h"
#include "node.h"
Include dependency graph for wrapper.h:

Go to the source code of this file.

Functions

RBT_VALUE_T RBT_DELETE (RBT_NODE_T *node, RBT_KEY_T key)
 
int RBT_HAS_KEY (RBT_NODE_T *node, RBT_KEY_T key)
 
RBT_VALUE_T RBT_INSERT (RBT_NODE_T *node, RBT_KEY_T key, RBT_VALUE_T value)
 
RBT_VALUE_T RBT_NODE_QUERY_WRAPPER (RBT_NODE_T *node, RBT_KEY_T key, rbt_query_action_t action, RBT_VALUE_T value)
 
RBT_VALUE_T RBT_RETRIEVE (RBT_NODE_T *node, RBT_KEY_T key)
 
RBT_VALUE_T RBT_SWAP (RBT_NODE_T *node, RBT_KEY_T key, RBT_VALUE_T value)
 

Detailed Description

Author
Xyne

Required Headers

  • query.h

Required Macro Definitions:

  • RBT_WRAPPER_H_PREFIX_

    The prefix for visible variable and function declarations in this header.

  • RBT_KEY_T

    The type of the keys that will be used. The only requirement for a key is that a pointer can be extracted from it and used to read the underlying contiguous bits.

  • RBT_KEY_COUNT_BITS(key)

    Return the number of bits in the key.

  • RBT_KEY_PTR(key)

    Return a pointer to the underlying bytes.

  • RBT_KEY_FPRINT(fd, key, len)

    Print a representation of the key to the given file descriptor. len is the length of the key in bytes.

Optional Macro Definitions

  • RBT_KEY_SIZE_FIXED

    The size of the key, in bytes, if it is fixed or if a maximum key size can be anticipated.

Function Documentation

◆ RBT_DELETE()

RBT_VALUE_T RBT_DELETE ( RBT_NODE_T node,
RBT_KEY_T  key 
)

A convenient wrapper for RBT_NODE_QUERY_WRAPPER() for deleting values.

Parameters
[in]nodeThe root node.
[in]keyThe query key.
Returns
The value returned by RBT_NODE_QUERY() for this action.

◆ RBT_HAS_KEY()

int RBT_HAS_KEY ( RBT_NODE_T node,
RBT_KEY_T  key 
)

Check if a key is present in the tree.

◆ RBT_INSERT()

RBT_VALUE_T RBT_INSERT ( RBT_NODE_T node,
RBT_KEY_T  key,
RBT_VALUE_T  value 
)

A convenient wrapper for RBT_NODE_QUERY_WRAPPER() for inserting values.

Parameters
[in]nodeThe root node.
[in]keyThe query key.
[in]valueThe value to insert.
Returns
The value returned by RBT_NODE_QUERY() for this action.

◆ RBT_NODE_QUERY_WRAPPER()

RBT_VALUE_T RBT_NODE_QUERY_WRAPPER ( RBT_NODE_T node,
RBT_KEY_T  key,
rbt_query_action_t  action,
RBT_VALUE_T  value 
)

A wrapper function around RBT_NODE_QUERY() that automatically casts the key to the required pointer type.

Parameters
[in]nodeThe root node.
[in]keyThe query key.
[in]actionThe action to perform.
[in]valueThe value with which to perform the action.
Returns
The value returned by RBT_NODE_QUERY() for this action.

◆ RBT_RETRIEVE()

RBT_VALUE_T RBT_RETRIEVE ( RBT_NODE_T node,
RBT_KEY_T  key 
)

A convenient wrapper for RBT_NODE_QUERY_WRAPPER() for retrieving values.

Parameters
[in]nodeThe root node.
[in]keyThe query key.
Returns
The value returned by RBT_NODE_QUERY() for this action.

◆ RBT_SWAP()

RBT_VALUE_T RBT_SWAP ( RBT_NODE_T node,
RBT_KEY_T  key,
RBT_VALUE_T  value 
)

A convenient wrapper for RBT_NODE_QUERY_WRAPPER() for swapping values.

Parameters
[in]nodeThe root node.
[in]keyThe query key.
[in]valueThe value to insert.
Returns
The value returned by RBT_NODE_QUERY() for this action.
Contact
echo xyne.archlinux.org | sed 's/\./@/'