bct - binary cell tree module

Module Description

The bct module implements an unbalanced binary tree with the key and data cell based. The implementation is non-recursive.

Module Words

Binary tree structure

bct% ( -- n )
Get the required space for a bct variable

Tree creation, initialisation and destruction

bct-init ( bct -- )
Initialise the tree

bct-(free) ( bct -- )
Free the nodes from the heap

bct-create ( "<spaces>name" -- ; -- bct )
Create a named binary tree in the dictionary

bct-new ( -- bct )
Create a new binary tree on the heap

bct-free ( bct -- )
Free the tree node from the heap

Member words

bct-length@ ( bct -- u )
Get the number of elements in the tree

bct-empty? ( bct -- flag )
Check for an empty tree

bct-compare@ ( bct -- xt )
Get the compare execution token for comparing keys

bct-compare! ( xt bct -- )
Set the compare execution token for comparing keys

Tree words

bct-clear ( bct -- )
Delete all nodes in the tree

bct-insert ( x1 x2 bct -- )
Insert data x2 with key x1 in the tree

bct-delete ( x1 bct -- false | x2 true )
Delete key x1 from the tree, return the cell data x2

bct-get ( x1 bct -- false | x2 true )
Get the data x2 related to key x1 from the tree

bct-has? ( x1 bct -- flag )
Check if the key x1 is present in the tree

bct-execute ( i*x xt bct -- j*x )
Execute xt for every key and data in the tree

Inspection

bct-dump ( bct -- )
Dump the tree node structure


generated 10-Apr-2008 by ofcfrth-0.5.0