Difference between revisions of "Cabal Common Library Doc BinSearch"

From Elite Wiki
m
m (updated internalVersion property)
Line 12: Line 12:
 
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;
 
{{CodeEx|codeex=var a = this.mySearch.internalVersion;
a -> 3}}
+
a -> 4}}
  
  

Revision as of 14:05, 18 May 2011

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 )

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"