virtualx-engine-docs/_sources/classes/class_poolvector2array.rst.txt

320 lines
14 KiB
Text
Raw Normal View History

2024-10-23 18:41:33 +02:00
:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/PoolVector2Array.xml.
.. _class_PoolVector2Array:
PoolVector2Array
================
A pooled array of :ref:`Vector2<class_Vector2>`\ s.
.. rst-class:: classref-introduction-group
Description
-----------
An array specifically designed to hold :ref:`Vector2<class_Vector2>`. Optimized for memory usage, does not fragment the memory.
\ **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:
::
var array = [PoolVector2Array()]
array[0].push_back(Vector2(12, 34))
print(array) # [[]] (empty PoolVector2Array within an Array)
Instead, the entire **PoolVector2Array** property must be *reassigned* with ``=`` for it to be changed:
::
var array = [PoolVector2Array()]
var pool_array = array[0]
pool_array.push_back(Vector2(12, 34))
array[0] = pool_array
print(array) # [[(12, 34)]] (PoolVector2Array with 1 element inside an Array)
.. rst-class:: classref-introduction-group
Tutorials
---------
- `2D Navigation Astar Demo <https://godotengine.org/asset-library/asset/519>`__
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`PoolVector2Array<class_PoolVector2Array_method_PoolVector2Array>` **(** :ref:`Array<class_Array>` from **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`append<class_PoolVector2Array_method_append>` **(** :ref:`Vector2<class_Vector2>` vector2 **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`append_array<class_PoolVector2Array_method_append_array>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` array **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_PoolVector2Array_method_clear>` **(** **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`count<class_PoolVector2Array_method_count>` **(** :ref:`Vector2<class_Vector2>` value **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`empty<class_PoolVector2Array_method_empty>` **(** **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`fill<class_PoolVector2Array_method_fill>` **(** :ref:`Vector2<class_Vector2>` vector2 **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`find<class_PoolVector2Array_method_find>` **(** :ref:`Vector2<class_Vector2>` value, :ref:`int<class_int>` from=0 **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`has<class_PoolVector2Array_method_has>` **(** :ref:`Vector2<class_Vector2>` value **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`insert<class_PoolVector2Array_method_insert>` **(** :ref:`int<class_int>` idx, :ref:`Vector2<class_Vector2>` vector2 **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`invert<class_PoolVector2Array_method_invert>` **(** **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`push_back<class_PoolVector2Array_method_push_back>` **(** :ref:`Vector2<class_Vector2>` vector2 **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`remove<class_PoolVector2Array_method_remove>` **(** :ref:`int<class_int>` idx **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`resize<class_PoolVector2Array_method_resize>` **(** :ref:`int<class_int>` idx **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`rfind<class_PoolVector2Array_method_rfind>` **(** :ref:`Vector2<class_Vector2>` value, :ref:`int<class_int>` from=-1 **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set<class_PoolVector2Array_method_set>` **(** :ref:`int<class_int>` idx, :ref:`Vector2<class_Vector2>` vector2 **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`size<class_PoolVector2Array_method_size>` **(** **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`sort<class_PoolVector2Array_method_sort>` **(** **)** |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_PoolVector2Array_method_PoolVector2Array:
.. rst-class:: classref-method
:ref:`PoolVector2Array<class_PoolVector2Array>` **PoolVector2Array** **(** :ref:`Array<class_Array>` from **)**
Constructs a new **PoolVector2Array**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_append:
.. rst-class:: classref-method
void **append** **(** :ref:`Vector2<class_Vector2>` vector2 **)**
Appends an element at the end of the array (alias of :ref:`push_back<class_PoolVector2Array_method_push_back>`).
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_append_array:
.. rst-class:: classref-method
void **append_array** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` array **)**
Appends a **PoolVector2Array** at the end of this array.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_clear:
.. rst-class:: classref-method
void **clear** **(** **)**
Clears the array. This is equivalent to using :ref:`resize<class_PoolVector2Array_method_resize>` with a size of ``0``.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **count** **(** :ref:`Vector2<class_Vector2>` value **)**
Returns the number of times an element is in the array.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_empty:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **empty** **(** **)**
Returns ``true`` if the array is empty.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_fill:
.. rst-class:: classref-method
void **fill** **(** :ref:`Vector2<class_Vector2>` vector2 **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_find:
.. rst-class:: classref-method
:ref:`int<class_int>` **find** **(** :ref:`Vector2<class_Vector2>` value, :ref:`int<class_int>` from=0 **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_has:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **has** **(** :ref:`Vector2<class_Vector2>` value **)**
Returns ``true`` if the array contains the given value.
\ **Note:** This is equivalent to using the ``in`` operator.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_insert:
.. rst-class:: classref-method
:ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` idx, :ref:`Vector2<class_Vector2>` vector2 **)**
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()``).
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_invert:
.. rst-class:: classref-method
void **invert** **(** **)**
Reverses the order of the elements in the array.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_push_back:
.. rst-class:: classref-method
void **push_back** **(** :ref:`Vector2<class_Vector2>` vector2 **)**
Inserts a :ref:`Vector2<class_Vector2>` at the end.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_remove:
.. rst-class:: classref-method
void **remove** **(** :ref:`int<class_int>` idx **)**
Removes an element from the array by index.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_resize:
.. rst-class:: classref-method
void **resize** **(** :ref:`int<class_int>` idx **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_rfind:
.. rst-class:: classref-method
:ref:`int<class_int>` **rfind** **(** :ref:`Vector2<class_Vector2>` value, :ref:`int<class_int>` from=-1 **)**
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.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_set:
.. rst-class:: classref-method
void **set** **(** :ref:`int<class_int>` idx, :ref:`Vector2<class_Vector2>` vector2 **)**
Changes the :ref:`Vector2<class_Vector2>` at the given index.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_size:
.. rst-class:: classref-method
:ref:`int<class_int>` **size** **(** **)**
Returns the number of elements in the array.
.. rst-class:: classref-item-separator
----
.. _class_PoolVector2Array_method_sort:
.. rst-class:: classref-method
void **sort** **(** **)**
Sorts the elements of the array in ascending order.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`