src/ADT/Tree/BinaryNode.php
public function toList( $dir = NULL )
	{
		$array	= array();
		if( !$dir || $dir == "lwr" )
		{
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
			$array = array_merge( $array, array( $this->value ) );
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
		}
		else if( $dir == "rwl" )
		{
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
			$array = array_merge( $array, array ($this->value));
			if( $this->left)
				$array = array_merge( $array, $this->left->toList( $dir ) );
		}
		else if( $dir == "wlr" )
		{
			$array = array_merge( $array, array ($this->value));
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
		}
		else if( $dir == "wrl" )
		{
			$array = array_merge( $array, array ($this->value));
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
		}
		return $array;
	}
public function toList( $dir = NULL )
	{
		$array	= array();
		if( !$dir || $dir == "lwr" )
		{
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
			$array = array_merge( $array, array( $this->value ) );
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
		}
		else if( $dir == "rwl" )
		{
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
			$array = array_merge( $array, array ($this->value));
			if( $this->left)
				$array = array_merge( $array, $this->left->toList( $dir ) );
		}
		else if( $dir == "wlr" )
		{
			$array = array_merge( $array, array ($this->value));
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
		}
		else if( $dir == "wrl" )
		{
			$array = array_merge( $array, array ($this->value));
			if( $this->right )
				$array = array_merge( $array, $this->right->toList( $dir ) );
			if( $this->left )
				$array = array_merge( $array, $this->left->toList( $dir ) );
		}
		return $array;
	}
public function toList ( $ dir = NULL ) { $ array = array ( ) ; if ( ! $ dir || $ dir == "lwr" ) { if ( $ this -> left ) $ array = array_merge ( $ array , $ this -> left -> toList ( $ dir ) ) ; $ array = array_merge ( $ array , array ( $ this -> value ) ) ; if ( $ this -> right ) $ array = array_merge ( $ array , $ this -> right -> toList ( $ dir ) ) ; } else if ( $ dir == "rwl" ) { if ( $ this -> right ) $ array = array_merge ( $ array , $ this -> right -> toList ( $ dir ) ) ; $ array = array_merge ( $ array , array ( $ this -> value ) ) ; if ( $ this -> left ) $ array = array_merge ( $ array , $ this -> left -> toList ( $ dir ) ) ; } else if ( $ dir == "wlr" ) { $ array = array_merge ( $ array , array ( $ this -> value ) ) ; if ( $ this -> left ) $ array = array_merge ( $ array , $ this -> left -> toList ( $ dir ) ) ; if ( $ this -> right ) $ array = array_merge ( $ array , $ this -> right -> toList ( $ dir ) ) ; } else if ( $ dir == "wrl" ) { $ array = array_merge ( $ array , array ( $ this -> value ) ) ; if ( $ this -> right ) $ array = array_merge ( $ array , $ this -> right -> toList ( $ dir ) ) ; if ( $ this -> left ) $ array = array_merge ( $ array , $ this -> left -> toList ( $ dir ) ) ; } return $ array ; }
Runs through the Tree in any Directions and returns the Tree as List.
@access		public
@param		string		$dir		Direction to run through the Tree (lwr|rwl|wlr|wrl)
@return		array
Runs through the Tree in any Directions and returns the Tree as List .