class_poolintarray.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/PoolIntArray.xml.
  6. .. _class_PoolIntArray:
  7. PoolIntArray
  8. ============
  9. A pooled array of integers (:ref:`int<class_int>`).
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. An array specifically designed to hold integer values (:ref:`int<class_int>`). Optimized for memory usage, does not fragment the memory.
  14. \ **Note:** This type is passed by value and not by reference. This means that when *mutating* a class property of type **PoolIntArray** or mutating a **PoolIntArray** within an :ref:`Array<class_Array>` or :ref:`Dictionary<class_Dictionary>`, changes will be lost:
  15. ::
  16. var array = [PoolIntArray()]
  17. array[0].push_back(1234)
  18. print(array) # [[]] (empty PoolIntArray within an Array)
  19. Instead, the entire **PoolIntArray** property must be *reassigned* with ``=`` for it to be changed:
  20. ::
  21. var array = [PoolIntArray()]
  22. var pool_array = array[0]
  23. pool_array.push_back(1234)
  24. array[0] = pool_array
  25. print(array) # [[1234]] (PoolIntArray with 1 element inside an Array)
  26. \ **Note:** This type is limited to signed 32-bit integers, which means it can only take values in the interval ``[-2^31, 2^31 - 1]``, i.e. ``[-2147483648, 2147483647]``. Exceeding those bounds will wrap around. In comparison, :ref:`int<class_int>` uses signed 64-bit integers which can hold much larger values.
  27. .. rst-class:: classref-reftable-group
  28. Methods
  29. -------
  30. .. table::
  31. :widths: auto
  32. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`PoolIntArray<class_PoolIntArray_method_PoolIntArray>` **(** :ref:`Array<class_Array>` from **)** |
  34. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`append<class_PoolIntArray_method_append>` **(** :ref:`int<class_int>` integer **)** |
  36. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`append_array<class_PoolIntArray_method_append_array>` **(** :ref:`PoolIntArray<class_PoolIntArray>` array **)** |
  38. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`clear<class_PoolIntArray_method_clear>` **(** **)** |
  40. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`count<class_PoolIntArray_method_count>` **(** :ref:`int<class_int>` value **)** |
  42. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`empty<class_PoolIntArray_method_empty>` **(** **)** |
  44. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`fill<class_PoolIntArray_method_fill>` **(** :ref:`int<class_int>` integer **)** |
  46. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`find<class_PoolIntArray_method_find>` **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=0 **)** |
  48. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`has<class_PoolIntArray_method_has>` **(** :ref:`int<class_int>` value **)** |
  50. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`insert<class_PoolIntArray_method_insert>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` integer **)** |
  52. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`invert<class_PoolIntArray_method_invert>` **(** **)** |
  54. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`push_back<class_PoolIntArray_method_push_back>` **(** :ref:`int<class_int>` integer **)** |
  56. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`remove<class_PoolIntArray_method_remove>` **(** :ref:`int<class_int>` idx **)** |
  58. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`resize<class_PoolIntArray_method_resize>` **(** :ref:`int<class_int>` idx **)** |
  60. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`rfind<class_PoolIntArray_method_rfind>` **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)** |
  62. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set<class_PoolIntArray_method_set>` **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` integer **)** |
  64. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`size<class_PoolIntArray_method_size>` **(** **)** |
  66. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`sort<class_PoolIntArray_method_sort>` **(** **)** |
  68. +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+
  69. .. rst-class:: classref-section-separator
  70. ----
  71. .. rst-class:: classref-descriptions-group
  72. Method Descriptions
  73. -------------------
  74. .. _class_PoolIntArray_method_PoolIntArray:
  75. .. rst-class:: classref-method
  76. :ref:`PoolIntArray<class_PoolIntArray>` **PoolIntArray** **(** :ref:`Array<class_Array>` from **)**
  77. Constructs a new **PoolIntArray**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  78. .. rst-class:: classref-item-separator
  79. ----
  80. .. _class_PoolIntArray_method_append:
  81. .. rst-class:: classref-method
  82. void **append** **(** :ref:`int<class_int>` integer **)**
  83. Appends an element at the end of the array (alias of :ref:`push_back<class_PoolIntArray_method_push_back>`).
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_PoolIntArray_method_append_array:
  87. .. rst-class:: classref-method
  88. void **append_array** **(** :ref:`PoolIntArray<class_PoolIntArray>` array **)**
  89. Appends a **PoolIntArray** at the end of this array.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_PoolIntArray_method_clear:
  93. .. rst-class:: classref-method
  94. void **clear** **(** **)**
  95. Clears the array. This is equivalent to using :ref:`resize<class_PoolIntArray_method_resize>` with a size of ``0``.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_PoolIntArray_method_count:
  99. .. rst-class:: classref-method
  100. :ref:`int<class_int>` **count** **(** :ref:`int<class_int>` value **)**
  101. Returns the number of times an element is in the array.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_PoolIntArray_method_empty:
  105. .. rst-class:: classref-method
  106. :ref:`bool<class_bool>` **empty** **(** **)**
  107. Returns ``true`` if the array is empty.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_PoolIntArray_method_fill:
  111. .. rst-class:: classref-method
  112. void **fill** **(** :ref:`int<class_int>` integer **)**
  113. Assigns the given value to all elements in the array. This can typically be used together with :ref:`resize<class_PoolIntArray_method_resize>` to create an array with a given size and initialized elements.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _class_PoolIntArray_method_find:
  117. .. rst-class:: classref-method
  118. :ref:`int<class_int>` **find** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=0 **)**
  119. Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed. Returns ``-1`` if ``from`` is out of bounds.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_PoolIntArray_method_has:
  123. .. rst-class:: classref-method
  124. :ref:`bool<class_bool>` **has** **(** :ref:`int<class_int>` value **)**
  125. Returns ``true`` if the array contains the given value.
  126. \ **Note:** This is equivalent to using the ``in`` operator.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_PoolIntArray_method_insert:
  130. .. rst-class:: classref-method
  131. :ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` integer **)**
  132. Inserts a new int at a given position in the array. The position must be valid, or at the end of the array (``idx == size()``).
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_PoolIntArray_method_invert:
  136. .. rst-class:: classref-method
  137. void **invert** **(** **)**
  138. Reverses the order of the elements in the array.
  139. .. rst-class:: classref-item-separator
  140. ----
  141. .. _class_PoolIntArray_method_push_back:
  142. .. rst-class:: classref-method
  143. void **push_back** **(** :ref:`int<class_int>` integer **)**
  144. Appends a value to the array.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_PoolIntArray_method_remove:
  148. .. rst-class:: classref-method
  149. void **remove** **(** :ref:`int<class_int>` idx **)**
  150. Removes an element from the array by index.
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _class_PoolIntArray_method_resize:
  154. .. rst-class:: classref-method
  155. void **resize** **(** :ref:`int<class_int>` idx **)**
  156. Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
  157. \ **Note:** Added elements are not automatically initialized to 0 and will contain garbage, i.e. indeterminate values.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_PoolIntArray_method_rfind:
  161. .. rst-class:: classref-method
  162. :ref:`int<class_int>` **rfind** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)**
  163. Searches the array in reverse order. Optionally, a start search index can be passed. If negative, the start index is considered relative to the end of the array. If the adjusted start index is out of bounds, this method searches from the end of the array.
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_PoolIntArray_method_set:
  167. .. rst-class:: classref-method
  168. void **set** **(** :ref:`int<class_int>` idx, :ref:`int<class_int>` integer **)**
  169. Changes the int at the given index.
  170. .. rst-class:: classref-item-separator
  171. ----
  172. .. _class_PoolIntArray_method_size:
  173. .. rst-class:: classref-method
  174. :ref:`int<class_int>` **size** **(** **)**
  175. Returns the number of elements in the array.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_PoolIntArray_method_sort:
  179. .. rst-class:: classref-method
  180. void **sort** **(** **)**
  181. Sorts the elements of the array in ascending order.
  182. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  183. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  184. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  185. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`