src/ADT/Tree/BalanceBinaryNode.php
public function add( $value )
	{
		if( !isset( $this->value ) )
			return $this->value = $value;
		if( $value == $this->value )
			return -1;
		if( $value < $this->value )
		{
			if( $this->left )
				$this->left->add( $value );
			else
				$this->left = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
		}
		else if( $value > $this->value )
		{
			if( $this->right )
				$this->right->add( $value );
			else
				$this->right = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
		}
		if ($this->balance)
		{
			$bf = $this->getBalance();
			if( $bf <= -1 * $this->balance || $bf >= $this->balance )
				$this->balanceTree();
		}
	}
public function add( $value )
	{
		if( !isset( $this->value ) )
			return $this->value = $value;
		if( $value == $this->value )
			return -1;
		if( $value < $this->value )
		{
			if( $this->left )
				$this->left->add( $value );
			else
				$this->left = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
		}
		else if( $value > $this->value )
		{
			if( $this->right )
				$this->right->add( $value );
			else
				$this->right = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
		}
		if ($this->balance)
		{
			$bf = $this->getBalance();
			if( $bf <= -1 * $this->balance || $bf >= $this->balance )
				$this->balanceTree();
		}
	}
public function add ( $ value ) { if ( ! isset ( $ this -> value ) ) return $ this -> value = $ value ; if ( $ value == $ this -> value ) return - 1 ; if ( $ value < $ this -> value ) { if ( $ this -> left ) $ this -> left -> add ( $ value ) ; else $ this -> left = new ADT_Tree_BalanceBinaryNode ( $ this -> balance , $ value ) ; } else if ( $ value > $ this -> value ) { if ( $ this -> right ) $ this -> right -> add ( $ value ) ; else $ this -> right = new ADT_Tree_BalanceBinaryNode ( $ this -> balance , $ value ) ; } if ( $ this -> balance ) { $ bf = $ this -> getBalance ( ) ; if ( $ bf <= - 1 * $ this -> balance || $ bf >= $ this -> balance ) $ this -> balanceTree ( ) ; } }
Adds a new Node To Tree.
@access		public
@param		mixed		value		Value of new Node
@return		int
Adds a new Node To Tree .