summaryrefslogtreecommitdiff
path: root/sys/src/libavl/avl.c
diff options
context:
space:
mode:
authorspew <devnull@localhost>2017-04-22 14:28:02 -0500
committerspew <devnull@localhost>2017-04-22 14:28:02 -0500
commit6261dcb06b11c2db815b2e259b25b18a9673d900 (patch)
tree3ec7f3b8808a9499c7b87a2923f2ac09845af6d6 /sys/src/libavl/avl.c
parent9cf519814591413493be10cfaa00853cb15e7a0b (diff)
replica: use libavl for avl tree implementation
Diffstat (limited to 'sys/src/libavl/avl.c')
-rw-r--r--sys/src/libavl/avl.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/src/libavl/avl.c b/sys/src/libavl/avl.c
index 8f1c8b075..c78c6a637 100644
--- a/sys/src/libavl/avl.c
+++ b/sys/src/libavl/avl.c
@@ -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;
+}