mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Add search methods for pool arrays
* has() * count() * find() * rfind()
This commit is contained in:
@@ -30,6 +30,13 @@
|
||||
Appends a [PoolIntArray] at the end of this array.
|
||||
</description>
|
||||
</method>
|
||||
<method name="count">
|
||||
<return type="int" />
|
||||
<argument index="0" name="value" type="int" />
|
||||
<description>
|
||||
Returns the number of times an element is in the array.
|
||||
</description>
|
||||
</method>
|
||||
<method name="empty">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
@@ -42,6 +49,22 @@
|
||||
Assigns the given value to all elements in the array. This can typically be used together with [method resize] to create an array with a given size and initialized elements.
|
||||
</description>
|
||||
</method>
|
||||
<method name="find">
|
||||
<return type="int" />
|
||||
<argument index="0" name="value" type="int" />
|
||||
<argument index="1" name="from" type="int" default="0" />
|
||||
<description>
|
||||
Searches the array for a value and returns its index or [code]-1[/code] if not found. Optionally, the initial search index can be passed. Returns [code]-1[/code] if [code]from[/code] is out of bounds.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="value" type="int" />
|
||||
<description>
|
||||
Returns [code]true[/code] if the array contains the given value.
|
||||
[b]Note:[/b] This is equivalent to using the [code]in[/code] operator.
|
||||
</description>
|
||||
</method>
|
||||
<method name="insert">
|
||||
<return type="int" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
@@ -74,6 +97,14 @@
|
||||
[b]Note:[/b] Added elements are not automatically initialized to 0 and will contain garbage, i.e. indeterminate values.
|
||||
</description>
|
||||
</method>
|
||||
<method name="rfind">
|
||||
<return type="int" />
|
||||
<argument index="0" name="value" type="int" />
|
||||
<argument index="1" name="from" type="int" default="-1" />
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set">
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<argument index="1" name="integer" type="int" />
|
||||
|
||||
Reference in New Issue
Block a user