Add search methods for packed arrays

* count()
* find()
* rfind()
This commit is contained in:
Haoyu Qiu
2022-05-07 20:16:11 +08:00
parent 563690347a
commit 380a53f02f
12 changed files with 268 additions and 0 deletions

View File

@ -61,6 +61,13 @@
Returns a new [PackedByteArray] with the data compressed. Set the compression mode using one of [enum File.CompressionMode]'s constants.
</description>
</method>
<method name="count" qualifiers="const">
<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="decode_double" qualifiers="const">
<return type="float" />
<argument index="0" name="byte_offset" type="int" />
@ -257,6 +264,14 @@
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" qualifiers="const">
<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.
</description>
</method>
<method name="get_string_from_ascii" qualifiers="const">
<return type="String" />
<description>
@ -352,6 +367,14 @@
Reverses the order of the elements in the array.
</description>
</method>
<method name="rfind" qualifiers="const">
<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.
</description>
</method>
<method name="set">
<return type="void" />
<argument index="0" name="index" type="int" />