btree.h 770 B

123456789101112131415161718192021222324252627282930313233343536
  1. typedef struct
  2. {
  3. void *key;
  4. void *data;
  5. int left;
  6. int right;
  7. } BTREE_NODE;
  8. typedef struct
  9. {
  10. BTREE_NODE *node; /* tree of values */
  11. int tlen; /* allocated tree size */
  12. int N; /* number of actual nodes in tree */
  13. int incr; /* number of nodes to add at a time */
  14. int cur;
  15. int (*cmp) (const void *, const void *); /* routine to compare keys */
  16. } BTREE;
  17. /* create.c */
  18. int btree_create(BTREE *, int (*)(const void *, const void *), int);
  19. /* find.c */
  20. int btree_find(const BTREE *, const void *, void **);
  21. /* free.c */
  22. int btree_free(BTREE *);
  23. /* next.c */
  24. int btree_next(BTREE *, void **, void **);
  25. /* rewind.c */
  26. int btree_rewind(BTREE *);
  27. /* update.c */
  28. int btree_update(BTREE *, const void *, int, const void *, int);