Difference between revisions of "Cabal Common Library Doc BinSearch"

From Elite Wiki
m
m (Retagged!)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
== Overview ==
 
== Overview ==
This is the main class for the binary search tree with its members.  This search tree uses two corresponding entries.
+
This is the main class for the binary search tree with its members and part of the [[Cabal_Common_Library]].  This search tree uses two corresponding entries.
  
 
Scripts can instantiate a copy, e.g.
 
Scripts can instantiate a copy, e.g.
{{CodeEx|codeex=this.mySearch = new Cabal_Common_BinSearch();}}
+
  this.mySearch = new worldScripts.Cabal_Common_Functions.Cabal_Common_BinSearch();
 +
Versions before v1.6 have used <code>this.myHelper = new Cabal_Common_2DCollision();</code>
  
 
Based on binary search tree by Nicholas Zakas.
 
Based on binary search tree by Nicholas Zakas.
Line 11: Line 12:
 
=== internalVersion ===
 
=== internalVersion ===
 
Number. Property to give OXPs a chance to check the required lib min. version easily. This number will be raised with every release.
 
Number. Property to give OXPs a chance to check the required lib min. version easily. This number will be raised with every release.
{{CodeEx|codeex=var a = this.mySearch.internalVersion;
+
  var a = this.mySearch.internalVersion;
a -> {{CCL_Int}}}}
+
 
 +
Current version is {{CodeEx|codeex={{CCL_Int}}}}
  
  
Line 28: Line 30:
 
:;nothing
 
:;nothing
  
{{CodeEx|codeex=this.mySearch.add("Hello","stupid example");}}
+
  this.mySearch.add("Hello","stupid example");
  
  
Line 42: Line 44:
 
:;value:Object.  Corresponding entry or false.
 
:;value:Object.  Corresponding entry or false.
  
{{CodeEx|codeex=var a = this.mySearch.contains("Hello");
+
  var a = this.mySearch.contains("Hello");
a -> "Stupid example"}}
+
  a -> "Stupid example"
  
  
Line 57: Line 59:
 
:;length:Number.  Number of nodes in searchtree.
 
:;length:Number.  Number of nodes in searchtree.
  
{{CodeEx|codeex=var a = this.mySearch.size();
+
  var a = this.mySearch.size();
a -> 1}}
+
  a -> 1
  
  
Line 72: Line 74:
 
:;result:Array.  Entries in search tree.
 
:;result:Array.  Entries in search tree.
  
{{CodeEx|codeex=var a = this.mySearch.toArray();
+
  var a = this.mySearch.toArray();
a -> "Hello","Stupid example"}}
+
  a -> "Hello","Stupid example"
  
  
Line 87: Line 89:
 
:;result:String.  Concatenation of all entries in search tree.
 
:;result:String.  Concatenation of all entries in search tree.
  
{{CodeEx|codeex=var a = this.mySearch.toString();
+
  var a = this.mySearch.toString();
a -> "Hello,Stupid example"}}
+
  a -> "Hello,Stupid example"
  
[[Category:OXPDoc]]
+
[[Category:OXP API's]]

Latest revision as of 14:14, 20 September 2023

Overview

This is the main class for the binary search tree with its members and part of the Cabal_Common_Library. This search tree uses two corresponding entries.

Scripts can instantiate a copy, e.g.

 this.mySearch = new worldScripts.Cabal_Common_Functions.Cabal_Common_BinSearch();

Versions before v1.6 have used this.myHelper = new Cabal_Common_2DCollision();

Based on binary search tree by Nicholas Zakas.


Properties

internalVersion

Number. Property to give OXPs a chance to check the required lib min. version easily. This number will be raised with every release.

 var a = this.mySearch.internalVersion;

Current version is

15


Methods

add()

add: function( key, value )
Profiler
Native 0.000038s
Extension 0.000013s
JS 0.000102s

Adds nodes to the search tree with the corresponding entry.

Parameters:

key
String. Add node with key.
value
Object. Corresponding entry

Returns:

nothing
 this.mySearch.add("Hello","stupid example");


contains()

contains: function( key )
Profiler
Native 0.000036s
Extension 0.000011s
JS 0.000069s

Returns corresponing entry or false.

Parameters:

key
String. Search for entry.

Returns:

value
Object. Corresponding entry or false.
 var a = this.mySearch.contains("Hello");
 a -> "Stupid example"


size()

size: function()
Profiler
Native 0.000036s
Extension 0.000011s
JS 0.000139s

Returns the number of nodes in the search tree.

Parameters:

none

Returns:

length
Number. Number of nodes in searchtree.
 var a = this.mySearch.size();
 a -> 1


toArray()

toArray: function()
Profiler
Native 0.000036s
Extension 0.000011s
JS 0.000133s

Returns an array conaining all nodes in the search tree. The nodes are processed in-order.

Parameters:

none

Returns:

result
Array. Entries in search tree.
 var a = this.mySearch.toArray();
 a -> "Hello","Stupid example"


toString()

toString: function( separator )
Profiler
Native 0.000035s
Extension 0.000010s
JS 0.000158s

Returns a comma-separated string consisting of all entries. The nodes are processed in-order.

Parameters:

separator
String. Optional. If specified separator is used to separate the elements instead of a commata.

Returns:

result
String. Concatenation of all entries in search tree.
 var a = this.mySearch.toString();
 a -> "Hello,Stupid example"