Cabal Common Library Doc BinSearch
Contents
Overview
This is the main class for the binary search tree with its members. This search tree uses two corresponding entries.
Scripts can instantiate a copy, e.g.
this.mySearch = new Cabal_Common_BinSearch(); |
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.myHelper.internalVersion;
a -> 3 |
Methods
add()
add: function( key, value ) |
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 ) |
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() |
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() |
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 ) |
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" |