avl.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #pragma lib "libavl.a"
  10. #pragma src "/sys/src/libavl"
  11. typedef struct Avl Avl;
  12. typedef struct Avltree Avltree;
  13. typedef struct Avlwalk Avlwalk;
  14. #pragma incomplete Avltree
  15. #pragma incomplete Avlwalk
  16. struct Avl
  17. {
  18. Avl *p; /* parent */
  19. Avl *n[2]; /* children */
  20. int bal; /* balance bits */
  21. };
  22. Avl *avlnext(Avlwalk *walk);
  23. Avl *avlprev(Avlwalk *walk);
  24. Avlwalk *avlwalk(Avltree *tree);
  25. void deleteavl(Avltree *tree, Avl *key, Avl **oldp);
  26. void endwalk(Avlwalk *walk);
  27. void insertavl(Avltree *tree, Avl *new, Avl **oldp);
  28. Avl *lookupavl(Avltree *tree, Avl *key);
  29. Avltree *mkavltree(int(*cmp)(Avl*, Avl*));
  30. Avl* searchavl(Avltree *tree, Avl *key, int neighbor);