38,16 → 38,15 |
|
#include <arch/types.h> |
|
/** |
* Macro for getting a pointer to the structure which contains the avltree |
* structure. |
/* |
* Makro for getting pointer to structure which enclosure avltree structure. |
* |
* @param link Pointer to the avltree structure. |
* @param type Name of the outer structure. |
* @param member Name of avltree attribute in the outer structure. |
* @param link Pointer to avltree structure. |
* @param type Name of outer structure. |
* @param member Name of avltree atribute in outer structure. |
*/ |
#define avltree_get_instance(link, type, member) \ |
((type *)(((uint8_t *)(link)) - ((uint8_t *) &(((type *) NULL)->member)))) |
#define avltree_get_instance(link,type,member) \ |
((type *)(((uint8_t *)(link)) - ((uint8_t *)&(((type *)NULL)->member)))) |
|
|
typedef struct avltree_node avltree_node_t; |
58,31 → 57,26 |
struct avltree_node |
{ |
/** |
* Pointer to the left descendant of this node. |
* Pointer to left descendand of this node. |
* |
* All keys of nodes in the left subtree are less than the key of this |
* node. |
* All keys of nodes in the left subtree are less then key of this node. |
*/ |
struct avltree_node *lft; |
|
/** |
* Pointer to the right descendant of this node. |
* Pointer to right descendand of this node. |
* |
* All keys of nodes in the right subtree are greater than the key of |
* this node. |
* All keys of nodes in the right subtree are greater then key of this node. |
*/ |
struct avltree_node *rgt; |
|
/** Pointer to the parent node. Root node has NULL parent. */ |
/** Pointer to parent node. Root node has NULL parent. */ |
struct avltree_node *par; |
|
/** Node's key. */ |
/** Nodes key. */ |
uint64_t key; |
|
/** |
* Difference between the heights of the left and the right subtree of |
* this node. |
*/ |
/** Difference between heights of left and right subtree of this node.*/ |
int8_t balance; |
}; |
|
93,12 → 87,12 |
struct avltree_node *root; |
|
/** |
* Base of the tree is a value that is smaller or equal than every value |
* in the tree (valid for positive keys otherwise ignore this atribute). |
* Base of tree is value that is smaller or equal then every value in tree |
* (valid for positive keys otherwise ignore this atribute). |
* |
* The base is added to the current key when a new node is inserted into |
* the tree. The base is changed to the key of the node which is deleted |
* with avltree_delete_min(). |
* Base is added to current key when new node is inserted into tree. |
* Base is changed to the key of node which is deleted with function |
* avltree_delete_min. |
*/ |
uint64_t base; |
}; |
116,7 → 110,7 |
|
/** Initialize node. |
* |
* @param node Node which is initialized. |
* @param Node which is initialized. |
*/ |
static inline void avltree_node_initialize(avltree_node_t *node) |
{ |
127,11 → 121,11 |
node->balance = 0; |
} |
|
extern avltree_node_t *avltree_find_min(avltree_t *t); |
extern avltree_node_t *avltree_search(avltree_t *t, uint64_t key); |
extern void avltree_insert(avltree_t *t, avltree_node_t *newnode); |
extern void avltree_delete(avltree_t *t, avltree_node_t *node); |
extern bool avltree_delete_min(avltree_t *t); |
avltree_node_t *avltree_find_min(avltree_t *t); |
avltree_node_t *avltree_search(avltree_t *t, uint64_t key); |
void avltree_insert(avltree_t *t, avltree_node_t *newnode); |
void avltree_delete(avltree_t *t, avltree_node_t *node); |
bool avltree_delete_min(avltree_t *t); |
|
#endif |
|