knowledge-database (beta)

Current group: aus.religion

- Implementing Balanced Binary Tree as JavaScript Object Class

- Implementing Balanced Binary Tree as JavaScript Object Class  
Qolon
From:Qolon
Subject:- Implementing Balanced Binary Tree as JavaScript Object Class
Date:Fri, 14 Jan 2005 06:08:13 GMT
oBinaryTree() is a beta version of the Javascript class written by Dolf Boek
14 January 2005
as implementation of a balanced binary tree and an adaption of the Visual C
implementation originally provided by Per Nilsson, 2 January 2002


It provides within JavaScript, a simple browser independent {Microsoft
Internet Explorer, Apple Safari, Firefox} virtual object manipulation with
CallBack() functionality that presently deal with Array([Fieldname, Value])
data types, and which currently includes the following routines:

nodeInsert() // Insert a new virtual object as node
oTree.nodeInsert(new oTree.vObject ("Client", Tokens), fnNodeCompare, null);

nodeFind() // Find Records based on search criteria
oTree.nodeFind(fnNodeFindDisplay, strSearch);

nodeRemove() // Delete nodes based on a search criteria
oTree.nodeRemove(null, null, strSearch);

nodeTraverse() // Traverse the nodes either as: Ascending, Descending,
ParentFirst, ParentLast
oTree.nodeTraverse("Ascending", fnDisplayDetails, null);

balanceTree(); // Perform a rebalancing of the binary tree
oTree.balanceTree(fnNodeCompare);

oTree.clearTree(); // Clears the binary tree.

A nodeModify() function is expected to be added within the next week.

The JavaScript code is provided as is, without any warranties expressed or
implied. And the author does not accept any consequence of data loss by its
usage. Due to the obscurity of browser cross-platform XML capabilities, it
is merely provided as an example of additional functionality that may be
obtained with platform independent and standards compliant JavaScript
language capabilities.

Feel free to drop me message at telos[*]bigpond.net.au (address is obviously
munged and [*] ought to be replaced with @), should you feel content to
deploy this JavaScrpt example.

- dolf
-
   

Copyright © 2006 knowledge-database   -   All rights reserved