y_simpletree.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /**--------------------------------------------------------------------------**\
  2. ===================================
  3. Y Sever Includes - Binary Tree Core
  4. ===================================
  5. Description:
  6. Provides functions to generate balanced binary search trees for efficient
  7. searching of large arrays by value. Left branch is less than, right branch
  8. is greater than or equal to for multiple matching values.
  9. Legal:
  10. Version: MPL 1.1
  11. The contents of this file are subject to the Mozilla Public License Version
  12. 1.1 (the "License"); you may not use this file except in compliance with
  13. the License. You may obtain a copy of the License at
  14. http://www.mozilla.org/MPL/
  15. Software distributed under the License is distributed on an "AS IS" basis,
  16. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  17. for the specific language governing rights and limitations under the
  18. License.
  19. The Original Code is the YSI binary tree include.
  20. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  21. Portions created by the Initial Developer are Copyright (C) 2011
  22. the Initial Developer. All Rights Reserved.
  23. Contributors:
  24. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  25. Thanks:
  26. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  27. ZeeX - Very productive conversations.
  28. koolk - IsPlayerinAreaEx code.
  29. TheAlpha - Danish translation.
  30. breadfish - German translation.
  31. Fireburn - Dutch translation.
  32. yom - French translation.
  33. 50p - Polish translation.
  34. Zamaroht - Spanish translation.
  35. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  36. for me to strive to better.
  37. Pixels^ - Running XScripters where the idea was born.
  38. Matite - Pestering me to release it and using it.
  39. Very special thanks to:
  40. Thiadmer - PAWN, whose limits continue to amaze me!
  41. Kye/Kalcor - SA:MP.
  42. SA:MP Team past, present and future - SA:MP.
  43. Version:
  44. 0.2
  45. Changelog:
  46. 12/04/15:
  47. Ported to y_simpletree for unique integer searching.
  48. 12/08/07:
  49. Fixed a bug with empty trees.
  50. 14/04/07:
  51. Updated header documentation with more than changelog.
  52. 10/04/07:
  53. Added parents for easy deletion.
  54. Added node deletion code.
  55. 08/04/07:
  56. Added Bintree_Add()
  57. 24/03/07:
  58. First version.
  59. Functions:
  60. Public:
  61. -
  62. Core:
  63. Bintree_QSort - Custom implementaion of QSort to keep pointers.
  64. Bintree_SortHalf - Itteratively balances halves of an array.
  65. Stock:
  66. Bintree_Generate - Generates a balanced binary tree from given input.
  67. Bintree_Reset - Resets a position in a tree.
  68. Bintree_FindValue - Finds the pointer for a value in the tree.
  69. Bintree_Add - Adds an item to a generated tree.
  70. Bintree_Delete - Removes an item from a tree.
  71. Bintree_UpdatePointers - Updates the pointers after a target change.
  72. Static:
  73. Bintree_Compress - Removes space from an altered tree.
  74. Bintree_FindMin - Finds the smallest value on a branch.
  75. Bintree_FindMax - Finds the largest value on a branch.
  76. Inline:
  77. Bintree_Sort - Entry point for Bintree_QSort.
  78. Bintree_Fill - Entry point for Bintree_SortHalf.
  79. API:
  80. -
  81. Callbacks:
  82. -
  83. Definitions:
  84. BINTREE_NO_BRANCH - Nowhere to go from the number in required direction.
  85. BINTREE_NOT_FOUND - Failure return.
  86. Enums:
  87. E_BINTREE_TREE - Structure of a leaf of a binary tree.
  88. E_BINTREE_INPUT - Structure of an array of data to be added to a tree.
  89. Macros:
  90. -
  91. Tags:
  92. Bintree - Binary tree type.
  93. Variables:
  94. Global:
  95. -
  96. Static:
  97. -
  98. Commands:
  99. -
  100. Compile options:
  101. -
  102. Operators:
  103. -
  104. \**--------------------------------------------------------------------------**/
  105. #if defined _INC_y_simpletree
  106. #endinput
  107. #endif
  108. #define _INC_y_simpletree
  109. #include "..\YSI_Internal\y_version"
  110. #include "..\YSI_Core\y_debug"
  111. #include "..\YSI_Core\y_utils"
  112. #include "y_binarytree"
  113. #include "y_simpletree/impl"
  114. #if defined YSI_TESTS
  115. #include "..\YSI_Core\y_testing"
  116. #include "y_simpletree/tests"
  117. #endif