Ported: Add search methods for pool arrays

* has()
* count()
* find()
* rfind()
- timothyqiu
3d1644f7c3
This commit is contained in:
Relintai 2022-07-27 15:44:10 +02:00
parent 4964f541e7
commit 48eee02c1d
10 changed files with 332 additions and 17 deletions

View File

@ -445,7 +445,10 @@ public:
}
bool contains(const T &p_val) const;
int find(const T &p_val) const;
int find(const T &p_val, int p_from = 0) const;
int rfind(const T &p_val, int p_from = -1) const;
bool count(const T &p_val) const;
bool has(const T &p_val) const;
bool is_locked() const {
return alloc && alloc->lock.get() > 0;
@ -527,19 +530,60 @@ bool PoolVector<T>::contains(const T &p_val) const {
}
template <class T>
int PoolVector<T>::find(const T &p_val) const {
Read r = read();
int s = size();
int PoolVector<T>::find(const T &p_val, int p_from) const {
if (p_from < 0) {
return -1;
}
for (int i = 0; i < s; ++i) {
const int s = size();
const Read r = read();
for (int i = p_from; i < s; i++) {
if (r[i] == p_val) {
return i;
}
}
return -1;
}
template <class T>
int PoolVector<T>::rfind(const T &p_val, int p_from) const {
const int s = size();
const Read r = read();
if (p_from < 0) {
p_from = s + p_from;
}
if (p_from < 0 || p_from >= s) {
p_from = s - 1;
}
for (int i = p_from; i >= 0; i--) {
if (r[i] == p_val) {
return i;
}
}
return -1;
}
template <class T>
bool PoolVector<T>::count(const T &p_val) const {
const int s = size();
const Read r = read();
int amount = 0;
for (int i = 0; i < s; i++) {
if (r[i] == p_val) {
amount++;
}
}
return amount;
}
template <class T>
bool PoolVector<T>::has(const T &p_val) const {
return find(p_val) != -1;
}
template <class T>
T PoolVector<T>::operator[](int p_index) const {
CRASH_BAD_INDEX(p_index, size());

View File

@ -766,6 +766,9 @@ struct _VariantCall {
VCALL_LOCALMEM2R(PoolByteArray, subarray);
VCALL_LOCALMEM1R(PoolByteArray, contains);
VCALL_LOCALMEM1R(PoolByteArray, find);
VCALL_LOCALMEM2R(PoolByteArray, rfind);
VCALL_LOCALMEM1R(PoolByteArray, count);
VCALL_LOCALMEM1R(PoolByteArray, has);
VCALL_LOCALMEM0(PoolByteArray, clear);
VCALL_LOCALMEM0R(PoolIntArray, size);
@ -782,6 +785,9 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolIntArray, invert);
VCALL_LOCALMEM1R(PoolIntArray, contains);
VCALL_LOCALMEM1R(PoolIntArray, find);
VCALL_LOCALMEM2R(PoolIntArray, rfind);
VCALL_LOCALMEM1R(PoolIntArray, count);
VCALL_LOCALMEM1R(PoolIntArray, has);
VCALL_LOCALMEM0(PoolIntArray, clear);
VCALL_LOCALMEM0R(PoolRealArray, size);
@ -798,6 +804,9 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolRealArray, invert);
VCALL_LOCALMEM1R(PoolRealArray, contains);
VCALL_LOCALMEM1R(PoolRealArray, find);
VCALL_LOCALMEM2R(PoolRealArray, rfind);
VCALL_LOCALMEM1R(PoolRealArray, count);
VCALL_LOCALMEM1R(PoolRealArray, has);
VCALL_LOCALMEM0(PoolRealArray, clear);
VCALL_LOCALMEM0R(PoolStringArray, size);
@ -815,6 +824,9 @@ struct _VariantCall {
VCALL_LOCALMEM1R(PoolStringArray, join);
VCALL_LOCALMEM1R(PoolStringArray, contains);
VCALL_LOCALMEM1R(PoolStringArray, find);
VCALL_LOCALMEM2R(PoolStringArray, rfind);
VCALL_LOCALMEM1R(PoolStringArray, count);
VCALL_LOCALMEM1R(PoolStringArray, has);
VCALL_LOCALMEM0(PoolStringArray, clear);
VCALL_LOCALMEM0R(PoolVector2Array, size);
@ -831,6 +843,9 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolVector2Array, invert);
VCALL_LOCALMEM1R(PoolVector2Array, contains);
VCALL_LOCALMEM1R(PoolVector2Array, find);
VCALL_LOCALMEM2R(PoolVector2Array, rfind);
VCALL_LOCALMEM1R(PoolVector2Array, count);
VCALL_LOCALMEM1R(PoolVector2Array, has);
VCALL_LOCALMEM0(PoolVector2Array, clear);
VCALL_LOCALMEM0R(PoolVector2iArray, size);
@ -847,6 +862,9 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolVector2iArray, invert);
VCALL_LOCALMEM1R(PoolVector2iArray, contains);
VCALL_LOCALMEM1R(PoolVector2iArray, find);
VCALL_LOCALMEM2R(PoolVector2iArray, rfind);
VCALL_LOCALMEM1R(PoolVector2iArray, count);
VCALL_LOCALMEM1R(PoolVector2iArray, has);
VCALL_LOCALMEM0(PoolVector2iArray, clear);
VCALL_LOCALMEM0R(PoolVector3Array, size);
@ -863,6 +881,9 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolVector3Array, invert);
VCALL_LOCALMEM1R(PoolVector3Array, contains);
VCALL_LOCALMEM1R(PoolVector3Array, find);
VCALL_LOCALMEM2R(PoolVector3Array, rfind);
VCALL_LOCALMEM1R(PoolVector3Array, count);
VCALL_LOCALMEM1R(PoolVector3Array, has);
VCALL_LOCALMEM0(PoolVector3Array, clear);
VCALL_LOCALMEM0R(PoolVector3iArray, size);
@ -879,6 +900,9 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolVector3iArray, invert);
VCALL_LOCALMEM1R(PoolVector3iArray, contains);
VCALL_LOCALMEM1R(PoolVector3iArray, find);
VCALL_LOCALMEM2R(PoolVector3iArray, rfind);
VCALL_LOCALMEM1R(PoolVector3iArray, count);
VCALL_LOCALMEM1R(PoolVector3iArray, has);
VCALL_LOCALMEM0(PoolVector3iArray, clear);
VCALL_LOCALMEM0R(PoolColorArray, size);
@ -895,6 +919,9 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolColorArray, invert);
VCALL_LOCALMEM1R(PoolColorArray, contains);
VCALL_LOCALMEM1R(PoolColorArray, find);
VCALL_LOCALMEM2R(PoolColorArray, rfind);
VCALL_LOCALMEM1R(PoolColorArray, count);
VCALL_LOCALMEM1R(PoolColorArray, has);
VCALL_LOCALMEM0(PoolColorArray, clear);
#define VCALL_PTR0(m_type, m_method) \
@ -2269,7 +2296,10 @@ void register_variant_methods() {
ADDFUNC0(POOL_BYTE_ARRAY, NIL, PoolByteArray, invert, varray());
ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, subarray, INT, "from", INT, "to", varray());
ADDFUNC1R(POOL_BYTE_ARRAY, BOOL, PoolByteArray, contains, INT, "value", varray())
ADDFUNC1R(POOL_BYTE_ARRAY, INT, PoolByteArray, find, INT, "value", varray())
ADDFUNC2R(POOL_BYTE_ARRAY, INT, PoolByteArray, find, INT, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_BYTE_ARRAY, INT, PoolByteArray, rfind, INT, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_BYTE_ARRAY, INT, PoolByteArray, count, INT, "value", varray());
ADDFUNC1R(POOL_BYTE_ARRAY, BOOL, PoolByteArray, has, INT, "value", varray());
ADDFUNC0(POOL_BYTE_ARRAY, NIL, PoolByteArray, clear, varray());
ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_ascii, varray());
@ -2291,7 +2321,10 @@ void register_variant_methods() {
ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, invert, varray());
ADDFUNC1R(POOL_INT_ARRAY, BOOL, PoolIntArray, contains, INT, "value", varray())
ADDFUNC1R(POOL_INT_ARRAY, INT, PoolIntArray, find, INT, "value", varray())
ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, find, INT, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, rfind, INT, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_INT_ARRAY, INT, PoolIntArray, count, INT, "value", varray());
ADDFUNC1R(POOL_INT_ARRAY, BOOL, PoolIntArray, has, INT, "value", varray());
ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, clear, varray());
ADDFUNC0R(POOL_REAL_ARRAY, INT, PoolRealArray, size, varray());
@ -2306,7 +2339,10 @@ void register_variant_methods() {
ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, invert, varray());
ADDFUNC1R(POOL_REAL_ARRAY, BOOL, PoolRealArray, contains, REAL, "value", varray())
ADDFUNC1R(POOL_REAL_ARRAY, INT, PoolRealArray, find, REAL, "value", varray())
ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, find, REAL, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, rfind, REAL, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_REAL_ARRAY, INT, PoolRealArray, count, REAL, "value", varray());
ADDFUNC1R(POOL_REAL_ARRAY, BOOL, PoolRealArray, has, REAL, "value", varray());
ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, clear, varray());
ADDFUNC0R(POOL_STRING_ARRAY, INT, PoolStringArray, size, varray());
@ -2322,7 +2358,10 @@ void register_variant_methods() {
ADDFUNC0(POOL_STRING_ARRAY, NIL, PoolStringArray, invert, varray());
ADDFUNC1(POOL_STRING_ARRAY, STRING, PoolStringArray, join, STRING, "delimiter", varray());
ADDFUNC1R(POOL_STRING_ARRAY, BOOL, PoolStringArray, contains, STRING, "value", varray())
ADDFUNC1R(POOL_STRING_ARRAY, INT, PoolStringArray, find, STRING, "value", varray())
ADDFUNC2R(POOL_STRING_ARRAY, INT, PoolStringArray, find, STRING, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_STRING_ARRAY, INT, PoolStringArray, rfind, STRING, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_STRING_ARRAY, INT, PoolStringArray, count, STRING, "value", varray());
ADDFUNC1R(POOL_STRING_ARRAY, BOOL, PoolStringArray, has, STRING, "value", varray());
ADDFUNC0(POOL_STRING_ARRAY, NIL, PoolStringArray, clear, varray());
ADDFUNC0R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, size, varray());
@ -2337,7 +2376,10 @@ void register_variant_methods() {
ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, resize, INT, "idx", varray());
ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, invert, varray());
ADDFUNC1R(POOL_VECTOR2_ARRAY, BOOL, PoolVector2Array, contains, VECTOR2, "value", varray())
ADDFUNC1R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, find, VECTOR2, "value", varray())
ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, find, VECTOR2, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, rfind, VECTOR2, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, count, VECTOR2, "value", varray());
ADDFUNC1R(POOL_VECTOR2_ARRAY, BOOL, PoolVector2Array, has, VECTOR2, "value", varray());
ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, clear, varray());
ADDFUNC0R(POOL_VECTOR2I_ARRAY, INT, PoolVector2iArray, size, varray());
@ -2352,7 +2394,10 @@ void register_variant_methods() {
ADDFUNC1(POOL_VECTOR2I_ARRAY, NIL, PoolVector2iArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_VECTOR2I_ARRAY, NIL, PoolVector2iArray, invert, varray());
ADDFUNC1R(POOL_VECTOR2I_ARRAY, BOOL, PoolVector2iArray, contains, VECTOR2I, "value", varray())
ADDFUNC1R(POOL_VECTOR2I_ARRAY, INT, PoolVector2iArray, find, VECTOR2I, "value", varray())
ADDFUNC2R(POOL_VECTOR2I_ARRAY, INT, PoolVector2iArray, find, VECTOR2I, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_VECTOR2I_ARRAY, INT, PoolVector2iArray, rfind, VECTOR2I, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_VECTOR2I_ARRAY, INT, PoolVector2iArray, count, VECTOR2I, "value", varray());
ADDFUNC1R(POOL_VECTOR2I_ARRAY, BOOL, PoolVector2iArray, has, VECTOR2I, "value", varray());
ADDFUNC0(POOL_VECTOR2I_ARRAY, NIL, PoolVector2iArray, clear, varray());
ADDFUNC0R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, size, varray());
@ -2367,7 +2412,10 @@ void register_variant_methods() {
ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, resize, INT, "idx", varray());
ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, invert, varray());
ADDFUNC1R(POOL_VECTOR3_ARRAY, BOOL, PoolVector3Array, contains, VECTOR3, "value", varray())
ADDFUNC1R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, find, VECTOR3, "value", varray())
ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, find, VECTOR3, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, rfind, VECTOR3, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, count, VECTOR3, "value", varray());
ADDFUNC1R(POOL_VECTOR3_ARRAY, BOOL, PoolVector3Array, has, VECTOR3, "value", varray());
ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, clear, varray());
ADDFUNC0R(POOL_VECTOR3I_ARRAY, INT, PoolVector3iArray, size, varray());
@ -2382,7 +2430,10 @@ void register_variant_methods() {
ADDFUNC1(POOL_VECTOR3I_ARRAY, NIL, PoolVector3iArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_VECTOR3I_ARRAY, NIL, PoolVector3iArray, invert, varray());
ADDFUNC1R(POOL_VECTOR3I_ARRAY, BOOL, PoolVector3iArray, contains, VECTOR3I, "value", varray())
ADDFUNC1R(POOL_VECTOR3I_ARRAY, INT, PoolVector3iArray, find, VECTOR3I, "value", varray())
ADDFUNC2R(POOL_VECTOR3I_ARRAY, INT, PoolVector3iArray, find, VECTOR3I, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_VECTOR3I_ARRAY, INT, PoolVector3iArray, rfind, VECTOR3I, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_VECTOR3I_ARRAY, INT, PoolVector3iArray, count, VECTOR3I, "value", varray());
ADDFUNC1R(POOL_VECTOR3I_ARRAY, BOOL, PoolVector3iArray, has, VECTOR3I, "value", varray());
ADDFUNC0(POOL_VECTOR3I_ARRAY, NIL, PoolVector3iArray, clear, varray());
ADDFUNC0R(POOL_COLOR_ARRAY, INT, PoolColorArray, size, varray());
@ -2397,7 +2448,10 @@ void register_variant_methods() {
ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_COLOR_ARRAY, NIL, PoolColorArray, invert, varray());
ADDFUNC1R(POOL_COLOR_ARRAY, BOOL, PoolColorArray, contains, COLOR, "value", varray())
ADDFUNC1R(POOL_COLOR_ARRAY, INT, PoolColorArray, find, COLOR, "value", varray())
ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, find, COLOR, "value", INT, "from", varray(-1))
ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, rfind, COLOR, "value", INT, "from", varray(-1));
ADDFUNC1R(POOL_COLOR_ARRAY, INT, PoolColorArray, count, COLOR, "value", varray());
ADDFUNC1R(POOL_COLOR_ARRAY, BOOL, PoolColorArray, has, COLOR, "value", varray());
ADDFUNC0(POOL_COLOR_ARRAY, NIL, PoolColorArray, clear, varray());
//pointerbased

View File

@ -205,7 +205,7 @@
<argument index="0" name="what" type="Variant" />
<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.
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="find_last">
@ -332,7 +332,7 @@
</method>
<method name="shuffle">
<description>
Shuffles the array such that the items will have a random order. This method uses the global random number generator common to methods such as [method @GDScript.randi]. Call [method @GDScript.randomize] to ensure that a new seed will be used each time if you want non-reproducible shuffling.
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="size">

View File

@ -36,6 +36,13 @@
Returns a new [PoolByteArray] with the data compressed. Set the compression mode using one of [enum File.CompressionMode]'s constants.
</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="decompress">
<return type="PoolByteArray" />
<argument index="0" name="buffer_size" type="int" />
@ -67,6 +74,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">
<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="get_string_from_ascii">
<return type="String" />
<description>
@ -79,6 +94,14 @@
Returns a copy of the array's contents as [String]. Slower than [method get_string_from_ascii] but supports UTF-8 encoded data. Use this function if you are unsure about the source of the data. For user input this function should always be preferred.
</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="hex_encode">
<return type="String" />
<description>
@ -121,6 +144,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="byte" type="int" />

View File

@ -29,6 +29,13 @@
Appends a [PoolColorArray] at the end of this array.
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="Color" />
<description>
Returns the number of times an element is in the array.
</description>
</method>
<method name="empty">
<return type="bool" />
<description>
@ -41,6 +48,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="Color" />
<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="Color" />
<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" />
@ -72,6 +95,14 @@
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.
</description>
</method>
<method name="rfind">
<return type="int" />
<argument index="0" name="value" type="Color" />
<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="color" type="Color" />

View File

@ -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" />

View File

@ -30,6 +30,13 @@
Appends a [PoolRealArray] at the end of this array.
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="float" />
<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="float" />
<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="float" />
<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="float" />
<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="value" type="float" />

View File

@ -30,6 +30,13 @@
Appends a [PoolStringArray] at the end of this array.
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="String" />
<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="String" />
<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="String" />
<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" />
@ -80,6 +103,14 @@
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.
</description>
</method>
<method name="rfind">
<return type="int" />
<argument index="0" name="value" type="String" />
<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="string" type="String" />

View File

@ -30,6 +30,13 @@
Appends a [PoolVector2Array] at the end of this array.
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="Vector2" />
<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="Vector2" />
<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="Vector2" />
<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" />
@ -73,6 +96,14 @@
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.
</description>
</method>
<method name="rfind">
<return type="int" />
<argument index="0" name="value" type="Vector2" />
<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="vector2" type="Vector2" />

View File

@ -29,6 +29,13 @@
Appends a [PoolVector3Array] at the end of this array.
</description>
</method>
<method name="count">
<return type="int" />
<argument index="0" name="value" type="Vector3" />
<description>
Returns the number of times an element is in the array.
</description>
</method>
<method name="empty">
<return type="bool" />
<description>
@ -41,6 +48,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="Vector3" />
<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="Vector3" />
<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" />
@ -72,6 +95,14 @@
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.
</description>
</method>
<method name="rfind">
<return type="int" />
<argument index="0" name="value" type="Vector3" />
<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="vector3" type="Vector3" />