avl.h 661 B

1234567891011121314151617181920212223242526
  1. #pragma lib "libavl.a"
  2. #pragma src "/sys/src/libavl"
  3. typedef struct Avl Avl;
  4. typedef struct Avltree Avltree;
  5. typedef struct Avlwalk Avlwalk;
  6. #pragma incomplete Avltree
  7. #pragma incomplete Avlwalk
  8. struct Avl
  9. {
  10. Avl *p; /* parent */
  11. Avl *n[2]; /* children */
  12. int bal; /* balance bits */
  13. };
  14. Avl *avlnext(Avlwalk *walk);
  15. Avl *avlprev(Avlwalk *walk);
  16. Avlwalk *avlwalk(Avltree *tree);
  17. void deleteavl(Avltree *tree, Avl *key, Avl **oldp);
  18. void endwalk(Avlwalk *walk);
  19. void insertavl(Avltree *tree, Avl *new, Avl **oldp);
  20. Avl *lookupavl(Avltree *tree, Avl *key);
  21. Avltree *mkavltree(int(*cmp)(Avl*, Avl*));
  22. Avl* searchavl(Avltree *tree, Avl *key, int neighbor);