From 48eee02c1dd62d76fb6b0234d569bc94a1e02698 Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 27 Jul 2022 15:44:10 +0200 Subject: [PATCH] Ported: Add search methods for pool arrays * has() * count() * find() * rfind() - timothyqiu https://github.com/godotengine/godot/commit/3d1644f7c3b639971aec03e9e0ed02a4b2a901d3 --- core/pool_vector.h | 56 ++++++++++++++++++++++--- core/variant_call.cpp | 72 ++++++++++++++++++++++++++++---- doc/classes/Array.xml | 4 +- doc/classes/PoolByteArray.xml | 31 ++++++++++++++ doc/classes/PoolColorArray.xml | 31 ++++++++++++++ doc/classes/PoolIntArray.xml | 31 ++++++++++++++ doc/classes/PoolRealArray.xml | 31 ++++++++++++++ doc/classes/PoolStringArray.xml | 31 ++++++++++++++ doc/classes/PoolVector2Array.xml | 31 ++++++++++++++ doc/classes/PoolVector3Array.xml | 31 ++++++++++++++ 10 files changed, 332 insertions(+), 17 deletions(-) diff --git a/core/pool_vector.h b/core/pool_vector.h index f3a631088..ccc3c6fcf 100644 --- a/core/pool_vector.h +++ b/core/pool_vector.h @@ -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::contains(const T &p_val) const { } template -int PoolVector::find(const T &p_val) const { - Read r = read(); - int s = size(); +int PoolVector::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 +int PoolVector::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 +bool PoolVector::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 +bool PoolVector::has(const T &p_val) const { + return find(p_val) != -1; +} + template T PoolVector::operator[](int p_index) const { CRASH_BAD_INDEX(p_index, size()); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 7ef1399e8..3db3702a0 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -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 diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 855ab6563..a00a65571 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -205,7 +205,7 @@ - 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. @@ -332,7 +332,7 @@ - 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. diff --git a/doc/classes/PoolByteArray.xml b/doc/classes/PoolByteArray.xml index d67d2b43f..90088226e 100644 --- a/doc/classes/PoolByteArray.xml +++ b/doc/classes/PoolByteArray.xml @@ -36,6 +36,13 @@ Returns a new [PoolByteArray] with the data compressed. Set the compression mode using one of [enum File.CompressionMode]'s constants. + + + + + Returns the number of times an element is in the array. + + @@ -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. + + + + + + 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. + + @@ -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. + + + + + Returns [code]true[/code] if the array contains the given value. + [b]Note:[/b] This is equivalent to using the [code]in[/code] operator. + + @@ -121,6 +144,14 @@ [b]Note:[/b] Added elements are not automatically initialized to 0 and will contain garbage, i.e. indeterminate values. + + + + + + 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. + + diff --git a/doc/classes/PoolColorArray.xml b/doc/classes/PoolColorArray.xml index b8066fa66..07caead25 100644 --- a/doc/classes/PoolColorArray.xml +++ b/doc/classes/PoolColorArray.xml @@ -29,6 +29,13 @@ Appends a [PoolColorArray] at the end of this array. + + + + + Returns the number of times an element is in the array. + + @@ -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. + + + + + + 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. + + + + + + + Returns [code]true[/code] if the array contains the given value. + [b]Note:[/b] This is equivalent to using the [code]in[/code] operator. + + @@ -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. + + + + + + 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. + + diff --git a/doc/classes/PoolIntArray.xml b/doc/classes/PoolIntArray.xml index 2ad889c35..c0a89964d 100644 --- a/doc/classes/PoolIntArray.xml +++ b/doc/classes/PoolIntArray.xml @@ -30,6 +30,13 @@ Appends a [PoolIntArray] at the end of this array. + + + + + Returns the number of times an element is in the array. + + @@ -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. + + + + + + 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. + + + + + + + Returns [code]true[/code] if the array contains the given value. + [b]Note:[/b] This is equivalent to using the [code]in[/code] operator. + + @@ -74,6 +97,14 @@ [b]Note:[/b] Added elements are not automatically initialized to 0 and will contain garbage, i.e. indeterminate values. + + + + + + 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. + + diff --git a/doc/classes/PoolRealArray.xml b/doc/classes/PoolRealArray.xml index 262f3e364..e8ca4ca55 100644 --- a/doc/classes/PoolRealArray.xml +++ b/doc/classes/PoolRealArray.xml @@ -30,6 +30,13 @@ Appends a [PoolRealArray] at the end of this array. + + + + + Returns the number of times an element is in the array. + + @@ -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. + + + + + + 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. + + + + + + + Returns [code]true[/code] if the array contains the given value. + [b]Note:[/b] This is equivalent to using the [code]in[/code] operator. + + @@ -74,6 +97,14 @@ [b]Note:[/b] Added elements are not automatically initialized to 0 and will contain garbage, i.e. indeterminate values. + + + + + + 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. + + diff --git a/doc/classes/PoolStringArray.xml b/doc/classes/PoolStringArray.xml index b21e23a61..df5e9e7bb 100644 --- a/doc/classes/PoolStringArray.xml +++ b/doc/classes/PoolStringArray.xml @@ -30,6 +30,13 @@ Appends a [PoolStringArray] at the end of this array. + + + + + Returns the number of times an element is in the array. + + @@ -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. + + + + + + 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. + + + + + + + Returns [code]true[/code] if the array contains the given value. + [b]Note:[/b] This is equivalent to using the [code]in[/code] operator. + + @@ -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. + + + + + + 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. + + diff --git a/doc/classes/PoolVector2Array.xml b/doc/classes/PoolVector2Array.xml index 8af38dcd2..194e74bdb 100644 --- a/doc/classes/PoolVector2Array.xml +++ b/doc/classes/PoolVector2Array.xml @@ -30,6 +30,13 @@ Appends a [PoolVector2Array] at the end of this array. + + + + + Returns the number of times an element is in the array. + + @@ -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. + + + + + + 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. + + + + + + + Returns [code]true[/code] if the array contains the given value. + [b]Note:[/b] This is equivalent to using the [code]in[/code] operator. + + @@ -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. + + + + + + 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. + + diff --git a/doc/classes/PoolVector3Array.xml b/doc/classes/PoolVector3Array.xml index e49a52098..b93189b61 100644 --- a/doc/classes/PoolVector3Array.xml +++ b/doc/classes/PoolVector3Array.xml @@ -29,6 +29,13 @@ Appends a [PoolVector3Array] at the end of this array. + + + + + Returns the number of times an element is in the array. + + @@ -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. + + + + + + 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. + + + + + + + Returns [code]true[/code] if the array contains the given value. + [b]Note:[/b] This is equivalent to using the [code]in[/code] operator. + + @@ -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. + + + + + + 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. + +