mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
classref: Sync with latest 4.0-dev
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
:github_url: hide
|
||||
|
||||
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
||||
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
|
||||
.. DO NOT EDIT THIS FILE, but the Array.xml source instead.
|
||||
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
||||
|
||||
@@ -67,31 +67,36 @@ Arrays can be concatenated using the ``+`` operator:
|
||||
|
||||
**Note:** When declaring an array with ``const``, the array itself can still be mutated by defining the values at individual indices or pushing/removing elements. Using ``const`` will only prevent assigning the constant with another value after it was initialized.
|
||||
|
||||
Constructors
|
||||
------------
|
||||
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`Array<class_Array>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedColorArray<class_PackedColorArray>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedFloat64Array<class_PackedFloat64Array>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedInt32Array<class_PackedInt32Array>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedInt64Array<class_PackedInt64Array>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedStringArray<class_PackedStringArray>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_constructor_Array>` **(** :ref:`PackedVector3Array<class_PackedVector3Array>` from **)** |
|
||||
+---------------------------+------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`Array<class_Array>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedColorArray<class_PackedColorArray>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedFloat64Array<class_PackedFloat64Array>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedInt32Array<class_PackedInt32Array>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedInt64Array<class_PackedInt64Array>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedStringArray<class_PackedStringArray>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`Array<class_Array_method_Array>` **(** :ref:`PackedVector3Array<class_PackedVector3Array>` from **)** |constructor| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`append<class_Array_method_append>` **(** :ref:`Variant<class_Variant>` value **)** |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
@@ -135,26 +140,6 @@ Methods
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`min<class_Array_method_min>` **(** **)** |const| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | **operator !=** **(** **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | **operator !=** **(** :ref:`Array<class_Array>` right **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | **operator +** **(** :ref:`Array<class_Array>` right **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | **operator <** **(** :ref:`Array<class_Array>` right **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | **operator <=** **(** :ref:`Array<class_Array>` right **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | **operator ==** **(** **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | **operator ==** **(** :ref:`Array<class_Array>` right **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | **operator >** **(** :ref:`Array<class_Array>` right **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | **operator >=** **(** :ref:`Array<class_Array>` right **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| void | **operator []** **(** :ref:`int<class_int>` index **)** |operator| |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`pop_at<class_Array_method_pop_at>` **(** :ref:`int<class_int>` position **)** |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Variant<class_Variant>` | :ref:`pop_back<class_Array_method_pop_back>` **(** **)** |
|
||||
@@ -186,76 +171,102 @@ Methods
|
||||
| void | :ref:`sort_custom<class_Array_method_sort_custom>` **(** :ref:`Callable<class_Callable>` func **)** |
|
||||
+-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
Method Descriptions
|
||||
-------------------
|
||||
Operators
|
||||
---------
|
||||
|
||||
.. _class_Array_method_Array:
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`operator !=<class_Array_operator_neq_bool>` **(** **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`operator !=<class_Array_operator_neq_bool>` **(** :ref:`Array<class_Array>` right **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`Array<class_Array>` | :ref:`operator +<class_Array_operator_sum_Array>` **(** :ref:`Array<class_Array>` right **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`operator <<class_Array_operator_lt_bool>` **(** :ref:`Array<class_Array>` right **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`operator <=<class_Array_operator_lte_bool>` **(** :ref:`Array<class_Array>` right **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`operator ==<class_Array_operator_eq_bool>` **(** **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`operator ==<class_Array_operator_eq_bool>` **(** :ref:`Array<class_Array>` right **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`operator ><class_Array_operator_gt_bool>` **(** :ref:`Array<class_Array>` right **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| :ref:`bool<class_bool>` | :ref:`operator >=<class_Array_operator_gte_bool>` **(** :ref:`Array<class_Array>` right **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
| void | :ref:`operator []<class_Array_operator_idx_void>` **(** :ref:`int<class_int>` index **)** |
|
||||
+---------------------------+-----------------------------------------------------------------------------------------------+
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** **)** |constructor|
|
||||
Constructor Descriptions
|
||||
------------------------
|
||||
|
||||
.. _class_Array_constructor_Array:
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** **)**
|
||||
|
||||
Constructs an empty ``Array``.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`Array<class_Array>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`Array<class_Array>` from **)**
|
||||
|
||||
Constructs an ``Array`` as a copy of the given ``Array``.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedByteArray<class_PackedByteArray>`.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedColorArray<class_PackedColorArray>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedColorArray<class_PackedColorArray>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedColorArray<class_PackedColorArray>`.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedFloat32Array<class_PackedFloat32Array>`.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedFloat64Array<class_PackedFloat64Array>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedFloat64Array<class_PackedFloat64Array>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedFloat64Array<class_PackedFloat64Array>`.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedInt32Array<class_PackedInt32Array>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedInt32Array<class_PackedInt32Array>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedInt32Array<class_PackedInt32Array>`.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedInt64Array<class_PackedInt64Array>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedInt64Array<class_PackedInt64Array>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedInt64Array<class_PackedInt64Array>`.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedStringArray<class_PackedStringArray>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedStringArray<class_PackedStringArray>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedStringArray<class_PackedStringArray>`.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedVector2Array<class_PackedVector2Array>`.
|
||||
|
||||
----
|
||||
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedVector3Array<class_PackedVector3Array>` from **)** |constructor|
|
||||
- :ref:`Array<class_Array>` **Array** **(** :ref:`PackedVector3Array<class_PackedVector3Array>` from **)**
|
||||
|
||||
Constructs an array from a :ref:`PackedVector3Array<class_PackedVector3Array>`.
|
||||
|
||||
----
|
||||
Method Descriptions
|
||||
-------------------
|
||||
|
||||
.. _class_Array_method_append:
|
||||
|
||||
@@ -536,62 +547,6 @@ Returns the minimum value contained in the array if all elements are of comparab
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_operator !=:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator !=** **(** **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
- :ref:`bool<class_bool>` **operator !=** **(** :ref:`Array<class_Array>` right **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_operator +:
|
||||
|
||||
- :ref:`Array<class_Array>` **operator +** **(** :ref:`Array<class_Array>` right **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_operator <:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator <** **(** :ref:`Array<class_Array>` right **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_operator <=:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator <=** **(** :ref:`Array<class_Array>` right **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_operator ==:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator ==** **(** **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
- :ref:`bool<class_bool>` **operator ==** **(** :ref:`Array<class_Array>` right **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_operator >:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator >** **(** :ref:`Array<class_Array>` right **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_operator >=:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator >=** **(** :ref:`Array<class_Array>` right **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_operator []:
|
||||
|
||||
- void **operator []** **(** :ref:`int<class_int>` index **)** |operator|
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_method_pop_at:
|
||||
|
||||
- :ref:`Variant<class_Variant>` **pop_at** **(** :ref:`int<class_int>` position **)**
|
||||
@@ -755,15 +710,19 @@ Sorts the array using a custom method. The custom method receives two arguments
|
||||
|
||||
.. code-tab:: gdscript
|
||||
|
||||
class MyCustomSorter:
|
||||
static func sort_ascending(a, b):
|
||||
if a[0] < b[0]:
|
||||
return true
|
||||
return false
|
||||
func sort_ascending(a, b):
|
||||
if a[0] < b[0]:
|
||||
return true
|
||||
return false
|
||||
|
||||
var my_items = [[5, "Potato"], [9, "Rice"], [4, "Tomato"]]
|
||||
my_items.sort_custom(MyCustomSorter.sort_ascending)
|
||||
print(my_items) # Prints [[4, Tomato], [5, Potato], [9, Rice]].
|
||||
func _ready():
|
||||
var my_items = [[5, "Potato"], [9, "Rice"], [4, "Tomato"]]
|
||||
my_items.sort_custom(sort_ascending)
|
||||
print(my_items) # Prints [[4, Tomato], [5, Potato], [9, Rice]].
|
||||
|
||||
# Descending, lambda version.
|
||||
my_items.sort_custom(func(a, b): return a[0] > b[0])
|
||||
print(my_items) # Prints [[9, Rice], [5, Potato], [4, Tomato]].
|
||||
|
||||
.. code-tab:: csharp
|
||||
|
||||
@@ -771,6 +730,63 @@ Sorts the array using a custom method. The custom method receives two arguments
|
||||
|
||||
|
||||
|
||||
Operator Descriptions
|
||||
---------------------
|
||||
|
||||
.. _class_Array_operator_neq_bool:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator !=** **(** **)**
|
||||
|
||||
----
|
||||
|
||||
- :ref:`bool<class_bool>` **operator !=** **(** :ref:`Array<class_Array>` right **)**
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_operator_sum_Array:
|
||||
|
||||
- :ref:`Array<class_Array>` **operator +** **(** :ref:`Array<class_Array>` right **)**
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_operator_lt_bool:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator <** **(** :ref:`Array<class_Array>` right **)**
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_operator_lte_bool:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator <=** **(** :ref:`Array<class_Array>` right **)**
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_operator_eq_bool:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator ==** **(** **)**
|
||||
|
||||
----
|
||||
|
||||
- :ref:`bool<class_bool>` **operator ==** **(** :ref:`Array<class_Array>` right **)**
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_operator_gt_bool:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator >** **(** :ref:`Array<class_Array>` right **)**
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_operator_gte_bool:
|
||||
|
||||
- :ref:`bool<class_bool>` **operator >=** **(** :ref:`Array<class_Array>` right **)**
|
||||
|
||||
----
|
||||
|
||||
.. _class_Array_operator_idx_void:
|
||||
|
||||
- void **operator []** **(** :ref:`int<class_int>` index **)**
|
||||
|
||||
.. |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.)`
|
||||
|
||||
Reference in New Issue
Block a user