Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2495 → Rev 2496

/branches/rcu/kernel/generic/include/adt/avl.h
38,15 → 38,16
 
#include <arch/types.h>
 
/*
* Makro for getting pointer to structure which enclosure avltree structure.
/**
* Macro for getting a pointer to the structure which contains the avltree
* structure.
*
* @param link Pointer to avltree structure.
* @param type Name of outer structure.
* @param member Name of avltree atribute in outer 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.
*/
#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;
57,26 → 58,31
struct avltree_node
{
/**
* Pointer to left descendand of this node.
* Pointer to the left descendant of this node.
*
* All keys of nodes in the left subtree are less then key of this node.
* All keys of nodes in the left subtree are less than the key of this
* node.
*/
struct avltree_node *lft;
/**
* Pointer to right descendand of this node.
* Pointer to the right descendant of this node.
*
* All keys of nodes in the right subtree are greater then key of this node.
* All keys of nodes in the right subtree are greater than the key of
* this node.
*/
struct avltree_node *rgt;
/** Pointer to parent node. Root node has NULL parent. */
/** Pointer to the parent node. Root node has NULL parent. */
struct avltree_node *par;
/** Nodes key. */
/** Node's key. */
uint64_t key;
/** Difference between heights of left and right subtree of this node.*/
/**
* Difference between the heights of the left and the right subtree of
* this node.
*/
int8_t balance;
};
 
87,12 → 93,12
struct avltree_node *root;
 
/**
* Base of tree is value that is smaller or equal then every value in tree
* (valid for positive keys otherwise ignore this atribute).
* 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 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.
* 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().
*/
uint64_t base;
};
110,7 → 116,7
 
/** Initialize node.
*
* @param Node which is initialized.
* @param node Node which is initialized.
*/
static inline void avltree_node_initialize(avltree_node_t *node)
{
121,11 → 127,11
node->balance = 0;
}
 
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);
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);
 
#endif