diff options
author | Russ Cox <rsc@swtch.com> | 2009-08-23 09:38:29 -0700 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2009-08-23 09:38:29 -0700 |
commit | 375b78fb110b7e1dd3686bc43aba38cf45c606e9 (patch) | |
tree | f216d60a656ec4cced9d7fba77a6f7e5fc7a0d12 /include | |
parent | da0a205ed60d81a85e1c71e0f31571337ba390a5 (diff) | |
download | plan9port-375b78fb110b7e1dd3686bc43aba38cf45c606e9.tar.gz plan9port-375b78fb110b7e1dd3686bc43aba38cf45c606e9.tar.bz2 plan9port-375b78fb110b7e1dd3686bc43aba38cf45c606e9.zip |
libavl: import from Plan 9
Diffstat (limited to 'include')
-rw-r--r-- | include/avl.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/avl.h b/include/avl.h new file mode 100644 index 00000000..d118ffd1 --- /dev/null +++ b/include/avl.h @@ -0,0 +1,27 @@ +/* #pragma lib "libavl.a" */ +/* #pragma src "/sys/src/libavl" */ + +AUTOLIB(avl) + +typedef struct Avl Avl; +typedef struct Avltree Avltree; +typedef struct Avlwalk Avlwalk; + +/* #pragma incomplete Avltree */ +/* #pragma incomplete Avlwalk */ + +struct Avl +{ + Avl *p; /* parent */ + Avl *n[2]; /* children */ + int bal; /* balance bits */ +}; + +Avl *avlnext(Avlwalk *walk); +Avl *avlprev(Avlwalk *walk); +Avlwalk *avlwalk(Avltree *tree); +void deleteavl(Avltree *tree, Avl *key, Avl **oldp); +void endwalk(Avlwalk *walk); +void insertavl(Avltree *tree, Avl *new, Avl **oldp); +Avl *lookupavl(Avltree *tree, Avl *key); +Avltree *mkavltree(int(*cmp)(Avl*, Avl*)); |