y_bintree.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * <library name="y_bintree">
  3. * <section>
  4. * Description
  5. * </section>
  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. * <section>
  10. * Version
  11. * </section>
  12. * 0.1.3
  13. * <section>
  14. * Functions
  15. * </section>
  16. * <subsection>
  17. * Core
  18. * </subsection><ul>
  19. * <symbol name="Bintree_QSort">Custom implementaion of QSort to keep pointers.</symbol>
  20. * <symbol name="Bintree_SortHalf">Itteratively balances halves of an array.</symbol>
  21. * </ul><subsection>
  22. * Stock
  23. * </subsection><ul>
  24. * <symbol name="Bintree_Generate">Generates a balanced binary tree from given input.</symbol>
  25. * <symbol name="Bintree_Reset">Resets a position in a tree.</symbol>
  26. * <symbol name="Bintree_FindValue">Finds the pointer for a value in the tree.</symbol>
  27. * <symbol name="Bintree_Add">Adds an item to a generated tree.</symbol>
  28. * <symbol name="Bintree_Delete">Removes an item from a tree.</symbol>
  29. * <symbol name="Bintree_UpdatePointers">Updates the pointers after a target change.</symbol>
  30. * </ul><subsection>
  31. * Static
  32. * </subsection><ul>
  33. * <symbol name="Bintree_Compress">Removes space from an altered tree.</symbol>
  34. * <symbol name="Bintree_FindMin">Finds the smallest value on a branch.</symbol>
  35. * <symbol name="Bintree_FindMax">Finds the largest value on a branch.</symbol>
  36. * </ul><subsection>
  37. * Inline
  38. * </subsection><ul>
  39. * <symbol name="Bintree_Sort">Entry point for Bintree_QSort.</symbol>
  40. * <symbol name="Bintree_Fill">Entry point for Bintree_SortHalf.</symbol>
  41. * </ul><section>
  42. * Definitions
  43. * </section><ul>
  44. * <symbol name="BINTREE_NO_BRANCH">Nowhere to go from the number in required direction.</symbol>
  45. * <symbol name="BINTREE_NOT_FOUND">Failure return.</symbol>
  46. * </ul><section>
  47. * Enums
  48. * </section><ul>
  49. * <symbol name="E_BINTREE_TREE">Structure of a leaf of a binary tree.</symbol>
  50. * <symbol name="E_BINTREE_INPUT">Structure of an array of data to be added to a tree.</symbol>
  51. * </ul><section>
  52. * Tags
  53. * </section><ul>
  54. * <symbol name="Bintree">Binary tree type.</symbol>
  55. * </ul>
  56. * </library>
  57. *//** *//*
  58. Legal:
  59. Version: MPL 1.1
  60. The contents of this file are subject to the Mozilla Public License Version
  61. 1.1 the "License"; you may not use this file except in compliance with
  62. the License. You may obtain a copy of the License at
  63. http://www.mozilla.org/MPL/
  64. Software distributed under the License is distributed on an "AS IS" basis,
  65. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  66. for the specific language governing rights and limitations under the
  67. License.
  68. The Original Code is the YSI framework.
  69. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  70. Portions created by the Initial Developer are Copyright C 2011
  71. the Initial Developer. All Rights Reserved.
  72. Contributors:
  73. Y_Less
  74. koolk
  75. JoeBullet/Google63
  76. g_aSlice/Slice
  77. Misiur
  78. samphunter
  79. tianmeta
  80. maddinat0r
  81. spacemud
  82. Crayder
  83. Dayvison
  84. Ahmad45123
  85. Zeex
  86. irinel1996
  87. Yiin-
  88. Chaprnks
  89. Konstantinos
  90. Masterchen09
  91. Southclaws
  92. PatchwerkQWER
  93. m0k1
  94. paulommu
  95. udan111
  96. Thanks:
  97. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  98. ZeeX - Very productive conversations.
  99. koolk - IsPlayerinAreaEx code.
  100. TheAlpha - Danish translation.
  101. breadfish - German translation.
  102. Fireburn - Dutch translation.
  103. yom - French translation.
  104. 50p - Polish translation.
  105. Zamaroht - Spanish translation.
  106. Los - Portuguese translation.
  107. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes for
  108. me to strive to better.
  109. Pixels^ - Running XScripters where the idea was born.
  110. Matite - Pestering me to release it and using it.
  111. Very special thanks to:
  112. Thiadmer - PAWN, whose limits continue to amaze me!
  113. Kye/Kalcor - SA:MP.
  114. SA:MP Team past, present and future - SA:MP.
  115. Optional plugins:
  116. Gamer_Z - GPS.
  117. Incognito - Streamer.
  118. Me - sscanf2, fixes2, Whirlpool.
  119. */
  120. #if !defined _INC_y_bintree
  121. #tryinclude "y_bintree\y_bintree_entry"
  122. #endif
  123. #if !defined _INC_y_bintree
  124. #tryinclude "YSI_Data\y_bintree\y_bintree_entry"
  125. #endif
  126. #if !defined _INC_y_bintree
  127. #tryinclude "YSI\YSI_Data\y_bintree\y_bintree_entry"
  128. #endif
  129. #if !defined _INC_y_bintree
  130. #tryinclude <YSI_Data\y_bintree\y_bintree_entry>
  131. #endif
  132. #if !defined _INC_y_bintree
  133. #tryinclude <YSI\YSI_Data\y_bintree\y_bintree_entry>
  134. #endif
  135. #if !defined _INC_y_bintree
  136. #error Could not find y_bintree
  137. #endif