.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_Array: Array ===== **Category:** Built-In Types Brief Description ----------------- Generic array datatype. Member Functions ---------------- +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`Array` **(** :ref:`PoolColorArray` from **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`Array` **(** :ref:`PoolVector3Array` from **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`Array` **(** :ref:`PoolVector2Array` from **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`Array` **(** :ref:`PoolStringArray` from **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`Array` **(** :ref:`PoolRealArray` from **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`Array` **(** :ref:`PoolIntArray` from **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`Array` **(** :ref:`PoolByteArray` from **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`append` **(** var value **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`back` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`count` **(** var value **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`empty` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`erase` **(** var value **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`find` **(** var what, :ref:`int` from=0 **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`find_last` **(** var value **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`front` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has` **(** var value **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`hash` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`insert` **(** :ref:`int` pos, var value **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`invert` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`pop_back` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`pop_front` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`push_back` **(** var value **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`push_front` **(** var value **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove` **(** :ref:`int` pos **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`resize` **(** :ref:`int` pos **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`rfind` **(** var what, :ref:`int` from=-1 **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`size` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`sort` **(** **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`sort_custom` **(** :ref:`Object` obj, :ref:`String` func **)** | +----------------------------+-----------------------------------------------------------------------------------------------------------------------------+ Description ----------- Generic array, contains several elements of any type, accessible by numerical index starting at 0. Negative indices can be used to count from the right, like in Python. Arrays are always passed by reference. Member Function Description --------------------------- .. _class_Array_Array: - :ref:`Array` **Array** **(** :ref:`PoolColorArray` from **)** Construct an array from a :ref:`PoolColorArray`. .. _class_Array_Array: - :ref:`Array` **Array** **(** :ref:`PoolVector3Array` from **)** Construct an array from a :ref:`PoolVector3Array`. .. _class_Array_Array: - :ref:`Array` **Array** **(** :ref:`PoolVector2Array` from **)** Construct an array from a :ref:`PoolVector2Array`. .. _class_Array_Array: - :ref:`Array` **Array** **(** :ref:`PoolStringArray` from **)** Construct an array from a :ref:`PoolStringArray`. .. _class_Array_Array: - :ref:`Array` **Array** **(** :ref:`PoolRealArray` from **)** Construct an array from a :ref:`PoolRealArray`. .. _class_Array_Array: - :ref:`Array` **Array** **(** :ref:`PoolIntArray` from **)** Construct an array from a :ref:`PoolIntArray`. .. _class_Array_Array: - :ref:`Array` **Array** **(** :ref:`PoolByteArray` from **)** Construct an array from a :ref:`PoolByteArray`. .. _class_Array_append: - void **append** **(** var value **)** Append an element at the end of the array (alias of :ref:`push_back`). .. _class_Array_back: - void **back** **(** **)** Returns the last element of the array if the array is not empty (size>0). .. _class_Array_clear: - void **clear** **(** **)** Clear the array (resize to 0). .. _class_Array_count: - :ref:`int` **count** **(** var value **)** Return the amount of times an element is in the array. .. _class_Array_empty: - :ref:`bool` **empty** **(** **)** Return true if the array is empty (size==0). .. _class_Array_erase: - void **erase** **(** var value **)** Remove the first occurrence of a value from the array. .. _class_Array_find: - :ref:`int` **find** **(** var what, :ref:`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. .. _class_Array_find_last: - :ref:`int` **find_last** **(** var value **)** Searches the array in reverse order for a value and returns its index or -1 if not found. .. _class_Array_front: - void **front** **(** **)** Returns the first element of the array if the array is not empty (size>0). .. _class_Array_has: - :ref:`bool` **has** **(** var value **)** Return true if the array contains given value. :: [ "inside", 7 ].has("inside") == true [ "inside", 7 ].has("outside") == false [ "inside", 7 ].has(7) == true [ "inside", 7 ].has("7") == false .. _class_Array_hash: - :ref:`int` **hash** **(** **)** Return a hashed integer value representing the array contents. .. _class_Array_insert: - void **insert** **(** :ref:`int` pos, var value **)** Insert a new element at a given position in the array. The position must be valid, or at the end of the array (pos==size()). .. _class_Array_invert: - void **invert** **(** **)** Reverse the order of the elements in the array (so first element will now be the last). .. _class_Array_pop_back: - void **pop_back** **(** **)** Remove the last element of the array. .. _class_Array_pop_front: - void **pop_front** **(** **)** Remove the first element of the array. .. _class_Array_push_back: - void **push_back** **(** var value **)** Append an element at the end of the array. .. _class_Array_push_front: - void **push_front** **(** var value **)** Add an element at the beginning of the array. .. _class_Array_remove: - void **remove** **(** :ref:`int` pos **)** Remove an element from the array by index. .. _class_Array_resize: - void **resize** **(** :ref:`int` pos **)** Resize the array to contain a different number of elements. If the array size is smaller, elements are cleared, if bigger, new elements are Null. .. _class_Array_rfind: - :ref:`int` **rfind** **(** var what, :ref:`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. .. _class_Array_size: - :ref:`int` **size** **(** **)** Return the amount of elements in the array. .. _class_Array_sort: - void **sort** **(** **)** Sort the array using natural order. .. _class_Array_sort_custom: - void **sort_custom** **(** :ref:`Object` obj, :ref:`String` func **)** Sort the array using a custom method. The arguments are an object that holds the method and the name of such method. The custom method receives two arguments (a pair of elements from the array) and must return true if the first argument is less than the second, and return false otherwise.