diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-01-25 21:14:30 +0100 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2021-01-26 00:02:55 +0100 |
commit | 7ce3cc0478261fb39344c98551cadab3ccb6265b (patch) | |
tree | 98d3ded5d82c35cc001293f685484dfee9e16ddb /doc | |
parent | 26c9e86bc0d4e46b0e1020b39b7ef81b431dec2b (diff) |
Document low performance of `Array.push_front()` and `Array.pop_front()`
Diffstat (limited to 'doc')
-rw-r--r-- | doc/classes/Array.xml | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index db5d377c62..909380b3b2 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -234,7 +234,9 @@ <argument index="0" name="value" type="Variant"> </argument> <description> - Removes the first occurrence of a value from the array. + Removes the first occurrence of a value from the array. To remove an element by index, use [method remove] instead. + [b]Note:[/b] This method acts in-place and doesn't return a value. + [b]Note:[/b] On large arrays, this method will be slower if the removed element is close to the beginning of the array (index 0). This is because all elements placed after the removed element have to be reindexed. </description> </method> <method name="find"> @@ -323,6 +325,8 @@ </argument> <description> Inserts a new element at a given position in the array. The position must be valid, or at the end of the array ([code]pos == size()[/code]). + [b]Note:[/b] This method acts in-place and doesn't return a value. + [b]Note:[/b] On large arrays, this method will be slower if the inserted element is close to the beginning of the array (index 0). This is because all elements placed after the newly inserted element have to be reindexed. </description> </method> <method name="invert"> @@ -421,14 +425,15 @@ <return type="Variant"> </return> <description> - Removes and returns the last element of the array. Returns [code]null[/code] if the array is empty, without printing an error message. + Removes and returns the last element of the array. Returns [code]null[/code] if the array is empty, without printing an error message. See also [method pop_front]. </description> </method> <method name="pop_front"> <return type="Variant"> </return> <description> - Removes and returns the first element of the array. Returns [code]null[/code] if the array is empty, without printing an error message. + Removes and returns the first element of the array. Returns [code]null[/code] if the array is empty, without printing an error message. See also [method pop_back]. + [b]Note:[/b] On large arrays, this method is much slower than [method pop_back] as it will reindex all the array's elements every time it's called. The larger the array, the slower [method pop_front] will be. </description> </method> <method name="push_back"> @@ -437,7 +442,7 @@ <argument index="0" name="value" type="Variant"> </argument> <description> - Appends an element at the end of the array. + Appends an element at the end of the array. See also [method push_front]. </description> </method> <method name="push_front"> @@ -446,7 +451,8 @@ <argument index="0" name="value" type="Variant"> </argument> <description> - Adds an element at the beginning of the array. + Adds an element at the beginning of the array. See also [method push_back]. + [b]Note:[/b] On large arrays, this method is much slower than [method push_back] as it will reindex all the array's elements every time it's called. The larger the array, the slower [method push_front] will be. </description> </method> <method name="remove"> @@ -455,7 +461,9 @@ <argument index="0" name="position" type="int"> </argument> <description> - Removes an element from the array by index. If the index does not exist in the array, nothing happens. + Removes an element from the array by index. If the index does not exist in the array, nothing happens. To remove an element by searching for its value, use [method erase] instead. + [b]Note:[/b] This method acts in-place and doesn't return a value. + [b]Note:[/b] On large arrays, this method will be slower if the removed element is close to the beginning of the array (index 0). This is because all elements placed after the removed element have to be reindexed. </description> </method> <method name="resize"> |