dev rstoetter cbalancedbinarytree cBalancedBinaryTreeNode - rstoetter/cbalancedbinarytree-php GitHub Wiki
rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode - of API Reference dev
- Class name: cBalancedBinaryTreeNode
- Namespace: rstoetter\cbalancedbinarytree
description
The class cBalancedBinaryTreeNode implements a single node in the balanced binary tree of the type cBalancedBinaryTree The class cBalancedBinaryTreeNode keeps the data part in the member variable m_data, which normally is represented by a class, which holds the data. Retrieve the data part with the method GetData( ) Normally you subclass your own class from cBalancedBinaryTreeNode, which will construct the Node with the data part
Usage:
class cMyTreeData {
// this class holds the data
public $m_data_1 = '';
public $m_data_2 = -1;
function __construct( string $data_1, int $data_2 ){
$this->m_data_1 = $data_1;
$this->m_data_1 = $data_2;
} // function __construct( )
public function GetKey( ) : string {
// calculate the unique sort key of the Tree
return "{$this->m_data_1}-{$this->m_data_2}";
} // function GetKey( )
// other methods here
} // class cMyTreeData
class cMyTreeNode extends \\rstoetter\\cbalancedbinarytree\\cBalancedBinaryTreeNode {
function __construct( string $data_1, int $data_2 ){
$obj_data = new cMyTreeData( $data_1, $data_2 );
parent::__construct( $obj_data->GetKey( ), $obj_data );
} // function __construct( )
public function __toString( ) : string {
$ret = $this->_data->GetKey();
return $ret;
} // function __toString( )
} // class cMyTreeNode
properties of class cBalancedBinaryTreeNode
- protected cBalancedBinaryTreeNode::$m_data
- protected cBalancedBinaryTreeNode::$m_key
- protected cBalancedBinaryTreeNode::$m_left
- protected cBalancedBinaryTreeNode::$m_parent
- protected cBalancedBinaryTreeNode::$m_right
- static public cBalancedBinaryTreeNode::$m_version
methods of class cBalancedBinaryTreeNode
public mixed rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::ClearData()
public \rstoetter\cbalancedbinarytree\the rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::GetData()
public \rstoetter\cbalancedbinarytree\the rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::GetKey()
public \rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode|null rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::GetLeft()
public \rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode|null rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::GetParent()
public \rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode|null rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::GetRight()
public mixed rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::SetData($data)
public mixed rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::SetKey(\rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode|null $key)
public mixed rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::SetLeft(\rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode|null $left)
public mixed rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::SetParent(\rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode|null $parent)
public mixed rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::SetRight(\rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode|null $right)
public \rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::__construct($key, $data)
public string rstoetter\cbalancedbinarytree\cBalancedBinaryTreeNode::__toString()