splay_tree.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*!
  2. Temelia - Splay tree interface.
  3. Copyright (C) 2008, 2009 Ceata (http://cod.ceata.org/proiecte/temelia).
  4. @author Dascalu Laurentiu
  5. This program is free software; you can redistribute it and
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 3
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef SPLAY_H_
  18. #define SPLAY_H_
  19. #include "platform.h"
  20. #include "binary_tree_common.h"
  21. struct _splay_tree_node;
  22. typedef struct _splay_tree_node *splay_tree_node;
  23. /*!
  24. * @see binary_tree_new
  25. */
  26. DECLSPEC splay_tree_t splay_tree_new(void *key);
  27. /*!
  28. * @see binary_tree_delete_node
  29. */
  30. DECLSPEC void splay_tree_delete_node(splay_tree_t splay);
  31. /*!
  32. * @see binary_tree_delete
  33. */
  34. DECLSPEC void splay_tree_delete(splay_tree_t splay);
  35. /*!
  36. * @see binary_tree_compare_trees
  37. */
  38. DECLSPEC int splay_tree_compare_trees(splay_tree_t splay1, splay_tree_t splay2,
  39. int compare(void *x, void *y, void *context), void *context);
  40. /*!
  41. * @see binary_tree_is_empty
  42. */
  43. DECLSPEC int splay_tree_is_empty(splay_tree_t splay);
  44. /*!
  45. * @see binary_tree_is_leaf
  46. */
  47. DECLSPEC int splay_tree_is_leaf(splay_tree_t splay);
  48. /*!
  49. * @see binary_tree_get_size
  50. * Complexity O(1)
  51. */
  52. DECLSPEC int splay_tree_get_size(splay_tree_t splay);
  53. /*!
  54. * @see binary_tree_get_root
  55. */
  56. DECLSPEC splay_tree_t splay_tree_get_root(splay_tree_t splay);
  57. /*!
  58. * @see binary_tree_get_key
  59. */
  60. DECLSPEC void *splay_tree_get_key(splay_tree_t splay);
  61. /*!
  62. * @see binary_tree_get_parent
  63. */
  64. DECLSPEC splay_tree_t splay_tree_get_parent(splay_tree_t splay);
  65. /*!
  66. * @see binary_tree_get_left_child
  67. */
  68. DECLSPEC splay_tree_t splay_tree_get_left_child(splay_tree_t splay);
  69. /*!
  70. * @see binary_tree_get_right_child
  71. */
  72. DECLSPEC splay_tree_t splay_tree_get_right_child(splay_tree_t splay);
  73. /*!
  74. * @see binary_tree_get_height
  75. */
  76. DECLSPEC int splay_tree_get_height(splay_tree_t splay);
  77. /*!
  78. * @see binary_tree_get_depth
  79. */
  80. DECLSPEC int splay_tree_get_depth(splay_tree_t splay);
  81. /*!
  82. * @see binary_search_tree_search
  83. */
  84. DECLSPEC splay_tree_t splay_tree_search(splay_tree_t splay, void *key, int compare(
  85. void *x, void *y, void *context), void *context);
  86. /*!
  87. * @see binary_search_tree_insert
  88. * @return New splay tree's root
  89. */
  90. DECLSPEC splay_tree_t splay_tree_insert(splay_tree_t splay, void *key, int compare(
  91. void *x, void *y, void *context), void *context);
  92. /*!
  93. * @see binary_search_tree_remove
  94. * @return The new splay tree's root
  95. */
  96. DECLSPEC splay_tree_t splay_tree_remove(splay_tree_t _splay_tree, void *key,
  97. int compare(void *x, void *y, void *context), void *context);
  98. /*!
  99. * @see binary_search_tree_get_min
  100. */
  101. DECLSPEC splay_tree_t splay_tree_get_min(splay_tree_t splay);
  102. /*!
  103. * @see binary_search_tree_get_max
  104. */
  105. DECLSPEC splay_tree_t splay_tree_get_max(splay_tree_t splay);
  106. /*!
  107. * @see binary_tree_preorder
  108. */
  109. DECLSPEC void splay_tree_preorder(splay_tree_t splay, void key_handler(void *x,
  110. void *context), void *context);
  111. /*!
  112. * @see binary_tree_inorder
  113. */
  114. DECLSPEC void splay_tree_inorder(splay_tree_t splay, void key_handler(void *x,
  115. void *context), void *context);
  116. /*!
  117. * @see binary_tree_reverse_inorder
  118. */
  119. DECLSPEC void splay_tree_reverse_inorder(splay_tree_t splay, void key_handler(void *x,
  120. void *context), void *context);
  121. /*!
  122. * @see binary_tree_postorder
  123. */
  124. DECLSPEC void splay_tree_postorder(splay_tree_t splay, void key_handler(void *x,
  125. void *context), void *context);
  126. /*!
  127. * @see binary_tree_level_order
  128. */
  129. DECLSPEC void splay_tree_level_order(splay_tree_t splay, void key_handler(void *x,
  130. void *context), void *context);
  131. /*!
  132. * @see binary_tree_show_indented
  133. */
  134. DECLSPEC void splay_tree_show_indented(splay_tree_t splay, void key_handler(void *x,
  135. int level, void *context), void *context);
  136. #endif /* SPLAY_H_ */