]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/man/2/avl
nusb(2): remove startdevs() reference, document getdev() (thanks BurnZeZ)
[plan9front.git] / sys / man / 2 / avl
index ddc7a7b922497c476ed64cefcd59e7b848ccba77..0dd98f844ac8117dd428e8c8dc367dad33528e30 100644 (file)
@@ -30,7 +30,9 @@ struct Avltree {
 Avltree *avlcreate(int(*cmp)(Avl*, Avl*));
 Avl     *avlinsert(Avltree *tree, Avl *new);
 Avl     *avldelete(Avltree *tree, Avl *key);
-Avl     *avllookup(Avltree *tree, Avl *key);
+Avl     *avllookup(Avltree *tree, Avl *key, int dir);
+Avl     *avlmin(Avltree *tree);
+Avl     *avlmax(Avltree *tree);
 Avl     *avlnext(Avl *n);
 Avl     *avlprev(Avl *n);
 
@@ -55,14 +57,25 @@ node into the tree and returns an existing
 node with the same key that has been removed
 from the tree and may be freed.
 .I Avllookup
-returns the
-node that matches the key or
-.B nil
-if no node matches.
+searches for a given key and returns
+the closest node less than the given key, 
+equal to,
+or the closest node greater than the key depending on whether
+.I dir
+is less than, equal to, or greater than zero, respectively. If
+.I dir
+is zero and there is no matching key, it returns
+.BR nil .
 .I Avldelete
 removes the node matching the key from the tree and returns
-it. It returns nil of no matching key is found.
+it. It returns nil if no matching key is found.
 .PP
+.I Avlmin
+returns the minimum
+.B Avl
+node in the tree and
+.I avlmax
+returns the maximum node.
 .I Avlnext
 returns the next 
 .B Avl 
@@ -104,7 +117,7 @@ get(Avltree *t, char *key)
        return h ? h->val : -1;
 }
 \fI\&...\fP
-       Avltree *t = avlcreate(AVL, nodecmp);
+       Avltree *t = avlcreate(nodecmp);
 
 .EE
 .SH SOURCE