ospf6_bintree.h 1014 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef _BINTREE_H_
  2. #define _BINTREE_H_
  3. struct bintree_node
  4. {
  5. struct bintree *tree;
  6. struct bintree_node *parent;
  7. int parent_link;
  8. #define BL_LEFT 0
  9. #define BL_RIGHT 1
  10. #define BL_MAX 2
  11. struct bintree_node *link[BL_MAX];
  12. #define bl_left link[BL_LEFT]
  13. #define bl_right link[BL_RIGHT]
  14. void *data;
  15. };
  16. struct bintree
  17. {
  18. int count;
  19. struct bintree_node *root;
  20. int (*cmp) (void *, void *);
  21. };
  22. void *bintree_lookup (void *data, struct bintree *tree);
  23. void *bintree_lookup_min (struct bintree *tree);
  24. void *bintree_lookup_max (struct bintree *tree);
  25. int bintree_add (void *data, struct bintree *tree);
  26. int bintree_remove (void *data, struct bintree *tree);
  27. void bintree_head (struct bintree *tree, struct bintree_node *node);
  28. int bintree_end (struct bintree_node *node);
  29. void bintree_next (struct bintree_node *node);
  30. struct bintree *bintree_create ();
  31. void bintree_delete (struct bintree *);
  32. void bintree_print (void (*print) (int, void *), struct bintree *);
  33. #endif /*_BINTREE_H_*/