class_poolvector2array.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/PoolVector2Array.xml.
  6. .. _class_PoolVector2Array:
  7. PoolVector2Array
  8. ================
  9. A pooled array of :ref:`Vector2<class_Vector2>`\ s.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. An array specifically designed to hold :ref:`Vector2<class_Vector2>`. 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 **PoolVector2Array** or mutating a **PoolVector2Array** within an :ref:`Array<class_Array>` or :ref:`Dictionary<class_Dictionary>`, changes will be lost:
  15. ::
  16. var array = [PoolVector2Array()]
  17. array[0].push_back(Vector2(12, 34))
  18. print(array) # [[]] (empty PoolVector2Array within an Array)
  19. Instead, the entire **PoolVector2Array** property must be *reassigned* with ``=`` for it to be changed:
  20. ::
  21. var array = [PoolVector2Array()]
  22. var pool_array = array[0]
  23. pool_array.push_back(Vector2(12, 34))
  24. array[0] = pool_array
  25. print(array) # [[(12, 34)]] (PoolVector2Array with 1 element inside an Array)
  26. .. rst-class:: classref-introduction-group
  27. Tutorials
  28. ---------
  29. - `2D Navigation Astar Demo <https://godotengine.org/asset-library/asset/519>`__
  30. .. rst-class:: classref-reftable-group
  31. Methods
  32. -------
  33. .. table::
  34. :widths: auto
  35. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`PoolVector2Array<class_PoolVector2Array_method_PoolVector2Array>` **(** :ref:`Array<class_Array>` from **)** |
  37. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`append<class_PoolVector2Array_method_append>` **(** :ref:`Vector2<class_Vector2>` vector2 **)** |
  39. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`append_array<class_PoolVector2Array_method_append_array>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` array **)** |
  41. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`count<class_PoolVector2Array_method_count>` **(** :ref:`Vector2<class_Vector2>` value **)** |
  43. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`empty<class_PoolVector2Array_method_empty>` **(** **)** |
  45. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`fill<class_PoolVector2Array_method_fill>` **(** :ref:`Vector2<class_Vector2>` vector2 **)** |
  47. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`find<class_PoolVector2Array_method_find>` **(** :ref:`Vector2<class_Vector2>` value, :ref:`int<class_int>` from=0 **)** |
  49. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`has<class_PoolVector2Array_method_has>` **(** :ref:`Vector2<class_Vector2>` value **)** |
  51. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`int<class_int>` | :ref:`insert<class_PoolVector2Array_method_insert>` **(** :ref:`int<class_int>` idx, :ref:`Vector2<class_Vector2>` vector2 **)** |
  53. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`invert<class_PoolVector2Array_method_invert>` **(** **)** |
  55. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`push_back<class_PoolVector2Array_method_push_back>` **(** :ref:`Vector2<class_Vector2>` vector2 **)** |
  57. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`remove<class_PoolVector2Array_method_remove>` **(** :ref:`int<class_int>` idx **)** |
  59. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`resize<class_PoolVector2Array_method_resize>` **(** :ref:`int<class_int>` idx **)** |
  61. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`int<class_int>` | :ref:`rfind<class_PoolVector2Array_method_rfind>` **(** :ref:`Vector2<class_Vector2>` value, :ref:`int<class_int>` from=-1 **)** |
  63. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`set<class_PoolVector2Array_method_set>` **(** :ref:`int<class_int>` idx, :ref:`Vector2<class_Vector2>` vector2 **)** |
  65. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`int<class_int>` | :ref:`size<class_PoolVector2Array_method_size>` **(** **)** |
  67. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`sort<class_PoolVector2Array_method_sort>` **(** **)** |
  69. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
  70. .. rst-class:: classref-section-separator
  71. ----
  72. .. rst-class:: classref-descriptions-group
  73. Method Descriptions
  74. -------------------
  75. .. _class_PoolVector2Array_method_PoolVector2Array:
  76. .. rst-class:: classref-method
  77. :ref:`PoolVector2Array<class_PoolVector2Array>` **PoolVector2Array** **(** :ref:`Array<class_Array>` from **)**
  78. Constructs a new **PoolVector2Array**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_PoolVector2Array_method_append:
  82. .. rst-class:: classref-method
  83. void **append** **(** :ref:`Vector2<class_Vector2>` vector2 **)**
  84. Appends an element at the end of the array (alias of :ref:`push_back<class_PoolVector2Array_method_push_back>`).
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_PoolVector2Array_method_append_array:
  88. .. rst-class:: classref-method
  89. void **append_array** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` array **)**
  90. Appends a **PoolVector2Array** at the end of this array.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_PoolVector2Array_method_count:
  94. .. rst-class:: classref-method
  95. :ref:`int<class_int>` **count** **(** :ref:`Vector2<class_Vector2>` value **)**
  96. Returns the number of times an element is in the array.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_PoolVector2Array_method_empty:
  100. .. rst-class:: classref-method
  101. :ref:`bool<class_bool>` **empty** **(** **)**
  102. Returns ``true`` if the array is empty.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_PoolVector2Array_method_fill:
  106. .. rst-class:: classref-method
  107. void **fill** **(** :ref:`Vector2<class_Vector2>` vector2 **)**
  108. Assigns the given value to all elements in the array. This can typically be used together with :ref:`resize<class_PoolVector2Array_method_resize>` to create an array with a given size and initialized elements.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_PoolVector2Array_method_find:
  112. .. rst-class:: classref-method
  113. :ref:`int<class_int>` **find** **(** :ref:`Vector2<class_Vector2>` value, :ref:`int<class_int>` from=0 **)**
  114. 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.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_PoolVector2Array_method_has:
  118. .. rst-class:: classref-method
  119. :ref:`bool<class_bool>` **has** **(** :ref:`Vector2<class_Vector2>` value **)**
  120. Returns ``true`` if the array contains the given value.
  121. \ **Note:** This is equivalent to using the ``in`` operator.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_PoolVector2Array_method_insert:
  125. .. rst-class:: classref-method
  126. :ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` idx, :ref:`Vector2<class_Vector2>` vector2 **)**
  127. Inserts a new element at a given position in the array. The position must be valid, or at the end of the array (``idx == size()``).
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_PoolVector2Array_method_invert:
  131. .. rst-class:: classref-method
  132. void **invert** **(** **)**
  133. Reverses the order of the elements in the array.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_PoolVector2Array_method_push_back:
  137. .. rst-class:: classref-method
  138. void **push_back** **(** :ref:`Vector2<class_Vector2>` vector2 **)**
  139. Inserts a :ref:`Vector2<class_Vector2>` at the end.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_PoolVector2Array_method_remove:
  143. .. rst-class:: classref-method
  144. void **remove** **(** :ref:`int<class_int>` idx **)**
  145. Removes an element from the array by index.
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_PoolVector2Array_method_resize:
  149. .. rst-class:: classref-method
  150. void **resize** **(** :ref:`int<class_int>` idx **)**
  151. 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.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_PoolVector2Array_method_rfind:
  155. .. rst-class:: classref-method
  156. :ref:`int<class_int>` **rfind** **(** :ref:`Vector2<class_Vector2>` value, :ref:`int<class_int>` from=-1 **)**
  157. 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.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_PoolVector2Array_method_set:
  161. .. rst-class:: classref-method
  162. void **set** **(** :ref:`int<class_int>` idx, :ref:`Vector2<class_Vector2>` vector2 **)**
  163. Changes the :ref:`Vector2<class_Vector2>` at the given index.
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_PoolVector2Array_method_size:
  167. .. rst-class:: classref-method
  168. :ref:`int<class_int>` **size** **(** **)**
  169. Returns the number of elements in the array.
  170. .. rst-class:: classref-item-separator
  171. ----
  172. .. _class_PoolVector2Array_method_sort:
  173. .. rst-class:: classref-method
  174. void **sort** **(** **)**
  175. Sorts the elements of the array in ascending order.
  176. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  177. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  178. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  179. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`