avl.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * \AUTHOR: Serena Pallecchi student of Computer Science University of Pisa (Italy)
  3. * Commission from Faunalia Pontedera (PI) www.faunalia.it
  4. *
  5. * This program is free software under the GPL (>=v2)
  6. * Read the COPYING file that comes with GRASS for details.
  7. *
  8. */
  9. #ifndef AVL_H
  10. #define AVL_H
  11. #include "GenericCell.h"
  12. typedef struct avl_node
  13. {
  14. generic_cell key; /* key field is a CELL or a DCELL or a FCELL */
  15. long counter; /* data */
  16. struct avl_node *father;
  17. struct avl_node *right_child;
  18. struct avl_node *left_child;
  19. } avl_node;
  20. typedef avl_node *avl_tree;
  21. /*table */
  22. typedef struct AVL_tableRow
  23. {
  24. generic_cell k;
  25. long tot;
  26. } AVL_tableRow;
  27. typedef AVL_tableRow *AVL_table;
  28. /* prototype of functions */
  29. avl_tree avl_make(const generic_cell k, const long n);
  30. avl_node *avl_find(const avl_tree root, const generic_cell k);
  31. int avl_add(avl_tree * root, const generic_cell k, const long n);
  32. long avl_to_array(avl_node * root, long i, AVL_table * a);
  33. long howManyCell(const avl_tree root, const generic_cell k);
  34. #endif