summaryrefslogtreecommitdiff
path: root/doc/classes/Array.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/Array.xml')
-rw-r--r--doc/classes/Array.xml64
1 files changed, 37 insertions, 27 deletions
diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml
index 3bb40755a6..9445a1732e 100644
--- a/doc/classes/Array.xml
+++ b/doc/classes/Array.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="Array" category="Built-In Types" version="3.0-alpha">
+<class name="Array" category="Built-In Types" version="3.0-beta">
<brief_description>
Generic array datatype.
</brief_description>
@@ -88,6 +88,32 @@
Returns the last element of the array if the array is not empty (size&gt;0).
</description>
</method>
+ <method name="bsearch">
+ <return type="int">
+ </return>
+ <argument index="0" name="value" type="var">
+ </argument>
+ <argument index="1" name="before" type="bool" default="True">
+ </argument>
+ <description>
+ Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a before specifier can be passed. If false, the returned index comes after all existing entries of the value in the array. Note that calling bsearch on an unsorted array results in unexpected behavior.
+ </description>
+ </method>
+ <method name="bsearch_custom">
+ <return type="int">
+ </return>
+ <argument index="0" name="value" type="var">
+ </argument>
+ <argument index="1" name="obj" type="Object">
+ </argument>
+ <argument index="2" name="func" type="String">
+ </argument>
+ <argument index="3" name="before" type="bool" default="True">
+ </argument>
+ <description>
+ Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search and a custom comparison method. Optionally, a before specifier can be passed. If false, the returned index comes after all existing entries of the value in the array. The custom method receives two arguments (an element from the array and the value searched for) and must return true if the first argument is less than the second, and return false otherwise. Note that calling bsearch on an unsorted array results in unexpected behavior.
+ </description>
+ </method>
<method name="clear">
<description>
Clear the array (resize to 0).
@@ -258,32 +284,16 @@
</argument>
<description>
Sort the array using a custom method and return reference to the array. The arguments are an object that holds the method and the name of such method. The custom method receives two arguments (a pair of elements from the array) and must return true if the first argument is less than the second, and return false otherwise. Note: you cannot randomize the return value as the heapsort algorithm expects a deterministic result. Doing so will result in unexpected behavior.
- </description>
- </method>
- <method name="bsearch">
- <return type="int">
- </return>
- <argument index="0" name="value" type="var">
- </argument>
- <argument index="1" name="before" type="bool" default="true">
- </argument>
- <description>
- Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a before specifier can be passed. If false, the returned index comes after all existing entries of the value in the array. Note that calling bsearch on an unsorted array results in unexpected behavior.
- </description>
- </method>
- <method name="bsearch_custom">
- <return type="int">
- </return>
- <argument index="0" name="value" type="var">
- </argument>
- <argument index="1" name="obj" type="Object">
- </argument>
- <argument index="2" name="func" type="String">
- </argument>
- <argument index="3" name="before" type="bool" default="true">
- </argument>
- <description>
- Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search and a custom comparison method. Optionally, a before specifier can be passed. If false, the returned index comes after all existing entries of the value in the array. The custom method receives two arguments (an element from the array and the value searched for) and must return true if the first argument is less than the second, and return false otherwise. Note that calling bsearch on an unsorted array results in unexpected behavior.
+ [codeblock]
+ class MyCustomSorter:
+ static func sort(a, b):
+ if a[0] &lt; b[0]:
+ return true
+ return false
+
+ var my_items = [[5, "Potato"], [9, "Rice"], [4, "Tomato"]]
+ my_items.sort_custom(MyCustomSorter, "sort")
+ [/codeblock]
</description>
</method>
</methods>