rebl.c 837 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "rebl.h"
  2. /* Rebl is a red/black tree structure Doesn't work yet */
  3. #include <stdlib.h>
  4. #ifdef UNDER_CONSTRUCTION___
  5. #define REBL_LESS(REBL, A, B) (REBL->compare(A,B) < 1)
  6. #define REBL_EQUAL(REBL, A, B) (REBL->compare(A,B) == 0)
  7. /* Red-Black tree colors */
  8. enum ReblColor_ { BLACK, RED } ;
  9. /* Red black tree node, also a red black tree in total. */
  10. struct Rebl_ {
  11. struct Rebl_ *parent; /* parent */
  12. struct Rebl_ *left; /* left child */
  13. struct Rebl_ *right; /* right child */
  14. ReblColor color; /* node color (BLACK, RED) */
  15. void * data; /* data stored in node */
  16. ReblCompare * compare; /* comparison/equality function to use. */
  17. };
  18. struct Rebl_ sentinel = { NULL, NULL, NULL, BLACK, NULL, NULL};
  19. #define SENTINEL &sentinel
  20. #endif