Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2420 → Rev 2421

/branches/rcu/kernel/generic/src/adt/avl.c
1,5 → 1,5
/*
* Copyright (c) 2006 Vojtech Mencl
* Copyright (c) 2007 Vojtech Mencl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
61,7 → 61,7
* @param t AVL tree.
* @param key Key to be searched.
*
* @return Pointer to value or NULL if there is no such key.
* @return Pointer to node or NULL if there is no such key.
*/
avltree_node_t *avltree_search(avltree_t *t, uint64_t key)
{
84,6 → 84,30
}
 
 
/** Find node with smallest key in AVL tree.
*
* @param t AVL tree.
*
* @return Pointer to node or NULL if there is no node in the tree.
*/
avltree_node_t *avltree_find_min(avltree_t *t)
{
avltree_node_t *p = t->root;
/*
* Check whether tree is empty.
*/
if (!p) return NULL;
/*
* Iteratively descend to the leftmost leaf in the tree.
*/
while (p->lft != NULL)
p = p->lft;
return p;
}
 
/** Insert new node into AVL tree.
*
* @param t AVL tree.
114,7 → 138,7
dpc = &t->root;
gpa = NULL;
top = t->root;
while (par = *dpc) {
while ((par = (*dpc)) != NULL) {
if (par->balance != 0) {
top = par;
}
670,7 → 694,7
*
* @param t AVL tree structure.
*/
avltree_node_t *avltree_delete_min(avltree_t *t)
bool avltree_delete_min(avltree_t *t)
{
avltree_node_t *node;
uint64_t key;