Location: PHPKode > scripts > LLRB Tree > llrb-tree/bNode.php
<?php

/*
 * 		bTree is copyright � 2009. EarthWalk Software.
 * 		Licensed under the Academic Free License version 3.0
 *      Refer to the file named Copyright provided with the source.
 */
/**
 * bNode.
 * 
 * Abstract class containing binary tree node abstract methods.
 * @author Jay Wheeler.
 * @version 1.0
 * @copyright � 2009. EarthWalk Software.
 * @license refer to Copyright file provided with the source.
 * @package LLRBTree.
 * @subpackage bNode.
 */
abstract class bNode implements iComparable
{
	protected $nkey;
	protected $ndata;

	protected $nleft;
	protected $nright;
	protected $nflag;

	/**
	 * __construct.
	 * 
	 * Create the class object.
	 * @param $key object key.
	 * @param $data (optional) object data.
	 * @return node object.
	 */
	public function __construct($key, $data=null, $flag=true)
	{
		$this->nkey = $key;
		$this->ndata = $data;

		$this->nleft = null;
		$this->nright = null;
		$this->nflag = $flag;
	}

	/**
	 * key.
	 * 
	 * Set/get the node key.
	 * @param $key the key to set, null to query only.
	 * @return $key
	 */
	abstract public function key($key=null);

	/**
	 * data.
	 * 
	 * Set/get the node data value.
	 * @param $data the value of the data to set, null to query only.
	 * @return $data
	 */
	abstract public function data($data=null);

	/**
	 * setNull.
	 * 
	 * Set the node data value to null.
	 * @return null
	 */
	abstract public function setNull();

	/**
	 * left.
	 * 
	 * Set/get the left child pointer.
	 * @param $link link to the left child (null to query).
	 * @return $link to the left pointer.
	 */
	abstract public function left($link=null);

	/**
	 * right.
	 * 
	 * Set/get pointer to the right child.
	 * @param $link (optional) pointer to the right child, null to query only.
	 * @return unknown_type
	 */
	abstract public function right($link=null);

	/**
	 * flag.
	 * 
	 * Set/get the flag.
	 * @param $flag general purpose flag, null = query only
	 * @return $flag is the current flag value
	 */
	abstract public function flag($flag=null);

	/**
	 * compare.
	 * 
	 * Compares the supplied key with the nodes key.  Returns 0 if equal, 1 if >, -1 if <
	 * @param $key is the key to be compared
	 * @return integer 0 = equal, 1 = >, -1 = <
	 */
	public function compare(self $key)
	{		
	}

}
Return current item: LLRB Tree