Difference between revisions of "Cabal Common Library Doc BinSearch"
m (updated internalVersion property) |
m |
||
Line 18: | Line 18: | ||
=== add() === | === add() === | ||
{{CodeEx|codeex=add: function( key, value )}} | {{CodeEx|codeex=add: function( key, value )}} | ||
+ | {{CodeExTime|native=0.000038|extension=0.000013|js=0.000102}} | ||
Adds nodes to the search tree with the corresponding entry. | Adds nodes to the search tree with the corresponding entry. | ||
Line 32: | Line 33: | ||
=== contains() === | === contains() === | ||
{{CodeEx|codeex=contains: function( key )}} | {{CodeEx|codeex=contains: function( key )}} | ||
+ | {{CodeExTime|native=0.000036|extension=0.000011|js=0.000069}} | ||
Returns corresponing entry or false. | Returns corresponing entry or false. | ||
Line 46: | Line 48: | ||
=== size() === | === size() === | ||
{{CodeEx|codeex=size: function()}} | {{CodeEx|codeex=size: function()}} | ||
+ | {{CodeExTime|native=0.000036|extension=0.000011|js=0.000139}} | ||
Returns the number of nodes in the search tree. | Returns the number of nodes in the search tree. | ||
Line 60: | Line 63: | ||
=== toArray() === | === toArray() === | ||
{{CodeEx|codeex=toArray: function()}} | {{CodeEx|codeex=toArray: function()}} | ||
+ | {{CodeExTime|native=0.000036|extension=0.000011|js=0.000133}} | ||
Returns an array conaining all nodes in the search tree. The nodes are processed in-order. | Returns an array conaining all nodes in the search tree. The nodes are processed in-order. | ||
Line 74: | Line 78: | ||
=== toString() === | === toString() === | ||
{{CodeEx|codeex=toString: function( separator )}} | {{CodeEx|codeex=toString: function( separator )}} | ||
+ | {{CodeExTime|native=0.000035|extension=0.000010|js=0.000158}} | ||
Returns a comma-separated string consisting of all entries. The nodes are processed in-order. | Returns a comma-separated string consisting of all entries. The nodes are processed in-order. | ||
Revision as of 21:35, 24 July 2011
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.mySearch.internalVersion;
a -> 4 |
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" |