avl(3): import changes from plan 9
R=rsc CC=plan9port.codebot http://codereview.appspot.com/4536105
This commit is contained in:
parent
f5a8ea6fd8
commit
e63f0507e9
1 changed files with 27 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ void deleteavl(Avltree *tree, Avl *key, Avl **oldp);
|
||||||
void endwalk(Avlwalk *walk);
|
void endwalk(Avlwalk *walk);
|
||||||
void insertavl(Avltree *tree, Avl *new, Avl **oldp);
|
void insertavl(Avltree *tree, Avl *new, Avl **oldp);
|
||||||
Avl *lookupavl(Avltree *tree, Avl *key);
|
Avl *lookupavl(Avltree *tree, Avl *key);
|
||||||
|
Avl *searchavl(Avltree *tree, Avl *key, int neighbor);
|
||||||
Avltree *mkavltree(int(*cmp)(Avl*, Avl*));
|
Avltree *mkavltree(int(*cmp)(Avl*, Avl*));
|
||||||
.EE
|
.EE
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|
@ -60,6 +61,32 @@ comparison function,
|
||||||
or
|
or
|
||||||
.B nil
|
.B nil
|
||||||
if none.
|
if none.
|
||||||
|
.PP
|
||||||
|
.I Searchavl
|
||||||
|
returns the
|
||||||
|
.I tree
|
||||||
|
node that matches
|
||||||
|
.I key
|
||||||
|
by
|
||||||
|
.IR tree 's
|
||||||
|
comparison function, if it exists.
|
||||||
|
If it does not, and
|
||||||
|
.I neighbor
|
||||||
|
is positive, it returns the nearest node whose
|
||||||
|
.I key
|
||||||
|
is greater or
|
||||||
|
.B nil
|
||||||
|
if there is none and, if
|
||||||
|
.I neighbor
|
||||||
|
is negative, it returns the nearest node whose
|
||||||
|
.I key
|
||||||
|
is less or
|
||||||
|
.B nil
|
||||||
|
if there is none.
|
||||||
|
It is an error to set
|
||||||
|
.I neighbor
|
||||||
|
to values other than \-1, 0, or +1.
|
||||||
|
.PP
|
||||||
.I Deleteavl
|
.I Deleteavl
|
||||||
removes the node matching
|
removes the node matching
|
||||||
.I key
|
.I key
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue