diff options
author | spew <devnull@localhost> | 2017-04-22 14:28:02 -0500 |
---|---|---|
committer | spew <devnull@localhost> | 2017-04-22 14:28:02 -0500 |
commit | 6261dcb06b11c2db815b2e259b25b18a9673d900 (patch) | |
tree | 3ec7f3b8808a9499c7b87a2923f2ac09845af6d6 /sys/src/libavl | |
parent | 9cf519814591413493be10cfaa00853cb15e7a0b (diff) |
replica: use libavl for avl tree implementation
Diffstat (limited to 'sys/src/libavl')
-rw-r--r-- | sys/src/libavl/avl.c | 29 |
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; +} |