]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/libavl/avl.c
upas/marshal: fix printinreplyto function
[plan9front.git] / sys / src / libavl / avl.c
index 8f1c8b0754c0c7cedaa9d948ab52550b9f075279..c78c6a6379eebae1b74e74c142706955041c3119 100644 (file)
@@ -310,3 +310,32 @@ walk1(int a, Avl *q)
                q = p;
        return p;
 }
+
+static Avl *bottom(Avltree*,int);
+
+Avl*
+avlmin(Avltree *t)
+{
+       return bottom(t, 0);
+}
+
+Avl*
+avlmax(Avltree *t)
+{
+       return bottom(t, 1);
+}
+
+static Avl*
+bottom(Avltree *t, int d)
+{
+       Avl *n;
+
+       if(t == nil)
+               return nil;
+       if(t->root == nil)
+               return nil;
+
+       for(n = t->root; n->c[d] != nil; n = n->c[d])
+               ;
+       return n;
+}