: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/PoolIntArray.xml. .. _class_PoolIntArray: PoolIntArray ============ A pooled array of integers (:ref:`int`). .. rst-class:: classref-introduction-group Description ----------- An array specifically designed to hold integer values (:ref:`int`). 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 **PoolIntArray** or mutating a **PoolIntArray** within an :ref:`Array` or :ref:`Dictionary`, changes will be lost: :: var array = [PoolIntArray()] array[0].push_back(1234) print(array) # [[]] (empty PoolIntArray within an Array) Instead, the entire **PoolIntArray** property must be *reassigned* with ``=`` for it to be changed: :: var array = [PoolIntArray()] var pool_array = array[0] pool_array.push_back(1234) array[0] = pool_array print(array) # [[1234]] (PoolIntArray with 1 element inside an Array) \ **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` uses signed 64-bit integers which can hold much larger values. .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolIntArray` | :ref:`PoolIntArray` **(** :ref:`Array` from **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`append` **(** :ref:`int` integer **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`append_array` **(** :ref:`PoolIntArray` array **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`count` **(** :ref:`int` value **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`empty` **(** **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`fill` **(** :ref:`int` integer **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`find` **(** :ref:`int` value, :ref:`int` from=0 **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has` **(** :ref:`int` value **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`insert` **(** :ref:`int` idx, :ref:`int` integer **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`invert` **(** **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`push_back` **(** :ref:`int` integer **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove` **(** :ref:`int` idx **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`resize` **(** :ref:`int` idx **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`rfind` **(** :ref:`int` value, :ref:`int` from=-1 **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set` **(** :ref:`int` idx, :ref:`int` integer **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`size` **(** **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ | void | :ref:`sort` **(** **)** | +-----------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_PoolIntArray_method_PoolIntArray: .. rst-class:: classref-method :ref:`PoolIntArray` **PoolIntArray** **(** :ref:`Array` from **)** Constructs a new **PoolIntArray**. Optionally, you can pass in a generic :ref:`Array` that will be converted. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_append: .. rst-class:: classref-method void **append** **(** :ref:`int` integer **)** Appends an element at the end of the array (alias of :ref:`push_back`). .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_append_array: .. rst-class:: classref-method void **append_array** **(** :ref:`PoolIntArray` array **)** Appends a **PoolIntArray** at the end of this array. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_clear: .. rst-class:: classref-method void **clear** **(** **)** Clears the array. This is equivalent to using :ref:`resize` with a size of ``0``. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_count: .. rst-class:: classref-method :ref:`int` **count** **(** :ref:`int` value **)** Returns the number of times an element is in the array. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_empty: .. rst-class:: classref-method :ref:`bool` **empty** **(** **)** Returns ``true`` if the array is empty. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_fill: .. rst-class:: classref-method void **fill** **(** :ref:`int` integer **)** Assigns the given value to all elements in the array. This can typically be used together with :ref:`resize` to create an array with a given size and initialized elements. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_find: .. rst-class:: classref-method :ref:`int` **find** **(** :ref:`int` value, :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. Returns ``-1`` if ``from`` is out of bounds. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_has: .. rst-class:: classref-method :ref:`bool` **has** **(** :ref:`int` 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_PoolIntArray_method_insert: .. rst-class:: classref-method :ref:`int` **insert** **(** :ref:`int` idx, :ref:`int` integer **)** 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()``). .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_invert: .. rst-class:: classref-method void **invert** **(** **)** Reverses the order of the elements in the array. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_push_back: .. rst-class:: classref-method void **push_back** **(** :ref:`int` integer **)** Appends a value to the array. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_remove: .. rst-class:: classref-method void **remove** **(** :ref:`int` idx **)** Removes an element from the array by index. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_resize: .. rst-class:: classref-method void **resize** **(** :ref:`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. \ **Note:** Added elements are not automatically initialized to 0 and will contain garbage, i.e. indeterminate values. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_rfind: .. rst-class:: classref-method :ref:`int` **rfind** **(** :ref:`int` value, :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. If the adjusted start index is out of bounds, this method searches from the end of the array. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_set: .. rst-class:: classref-method void **set** **(** :ref:`int` idx, :ref:`int` integer **)** Changes the int at the given index. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_method_size: .. rst-class:: classref-method :ref:`int` **size** **(** **)** Returns the number of elements in the array. .. rst-class:: classref-item-separator ---- .. _class_PoolIntArray_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.)`