src/Datastructure/Lists/ArrayLists/StringBuilder.php
private function arrayListToStringBuilder(ArrayList $arrayList, bool $reverse = false) {
        $stringBuilder = new StringBuilder();
        if ($reverse) {
            $stack = new Stack();
            foreach ($arrayList as $item) {
                if (null !== $item) {
                    $stack->push($item);
                }
            }
            while (!$stack->isEmpty()) {
                $stringBuilder->append($stack->pop());
            }
        } else {
            $queue = new Queue();
            foreach ($arrayList as $item) {
                if (null !== $item) {
                    $queue->enqueue($item);
                }

            }
            while (!$queue->isEmpty()) {
                $stringBuilder->append($queue->dequeue());
            }
        }
        return $stringBuilder;
    }
private function arrayListToStringBuilder(ArrayList $arrayList, bool $reverse = false) {
        $stringBuilder = new StringBuilder();
        if ($reverse) {
            $stack = new Stack();
            foreach ($arrayList as $item) {
                if (null !== $item) {
                    $stack->push($item);
                }
            }
            while (!$stack->isEmpty()) {
                $stringBuilder->append($stack->pop());
            }
        } else {
            $queue = new Queue();
            foreach ($arrayList as $item) {
                if (null !== $item) {
                    $queue->enqueue($item);
                }

            }
            while (!$queue->isEmpty()) {
                $stringBuilder->append($queue->dequeue());
            }
        }
        return $stringBuilder;
    }
private function arrayListToStringBuilder ( ArrayList $ arrayList , bool $ reverse = false ) { $ stringBuilder = new StringBuilder ( ) ; if ( $ reverse ) { $ stack = new Stack ( ) ; foreach ( $ arrayList as $ item ) { if ( null !== $ item ) { $ stack -> push ( $ item ) ; } } while ( ! $ stack -> isEmpty ( ) ) { $ stringBuilder -> append ( $ stack -> pop ( ) ) ; } } else { $ queue = new Queue ( ) ; foreach ( $ arrayList as $ item ) { if ( null !== $ item ) { $ queue -> enqueue ( $ item ) ; } } while ( ! $ queue -> isEmpty ( ) ) { $ stringBuilder -> append ( $ queue -> dequeue ( ) ) ; } } return $ stringBuilder ; }
converts a array list to a string builder

@param ArrayList $arrayList
@param bool      $reverse
@return StringBuilder
converts a array list to a string builder