@@ -33,7 +33,7 @@ |
||
| 33 | 33 | { |
| 34 | 34 | $resultList = new ArrayList(); |
| 35 | 35 | if ($node !== null) { |
| 36 | - foreach($node->getChildren() as $child) { |
|
| 36 | + foreach ($node->getChildren() as $child) { |
|
| 37 | 37 | $resultList->merge($child->accept($this)); |
| 38 | 38 | } |
| 39 | 39 | $resultList->append($node->getItem()); |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $resultList = new ArrayList(); |
| 34 | 34 | if ($node !== null) { |
| 35 | 35 | $resultList->append($node->getItem()); |
| 36 | - foreach($node->getChildren() as $child) { |
|
| 36 | + foreach ($node->getChildren() as $child) { |
|
| 37 | 37 | $resultList->merge($child->accept($this)); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | |
| 48 | 48 | public function __toString() |
| 49 | 49 | { |
| 50 | - return (string)$this->value; |
|
| 50 | + return (string) $this->value; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | public function visit(TreeNodeInterface $node): ArrayListInterface |
| 32 | 32 | { |
| 33 | 33 | if (!$node instanceof BinaryNodeInterface) { |
| 34 | - throw new InvalidArgumentException(BinaryNodeInterface::class . " expected, got " . get_class($node) . "."); |
|
| 34 | + throw new InvalidArgumentException(BinaryNodeInterface::class." expected, got ".get_class($node)."."); |
|
| 35 | 35 | } |
| 36 | 36 | $resultList = new ArrayList(); |
| 37 | 37 | if ($node !== null) { |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | ->child(5) |
| 29 | 29 | ->child(6) |
| 30 | 30 | ->endSubTree(); |
| 31 | -echo $tree->count() . " items added to tree\n"; |
|
| 31 | +echo $tree->count()." items added to tree\n"; |
|
| 32 | 32 | |
| 33 | 33 | $rootNode = $tree->getRoot(); |
| 34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | echo "no leaf node\n"; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | -echo "2. child of root has a height of " . $rootNode->getChildren()[1]->getHeight() . "\n"; |
|
| 42 | +echo "2. child of root has a height of ".$rootNode->getChildren()[1]->getHeight()."\n"; |
|
| 43 | 43 | |
| 44 | 44 | echo "Values of level 3 nodes: "; |
| 45 | 45 | foreach ($rootNode->getChildren() as $lev1) { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | foreach ($lev1->getChildren() as $lev2) { |
| 48 | 48 | if (count($lev2->getChildren()) > 0) { |
| 49 | 49 | foreach ($lev2->getChildren() as $lev3) { |
| 50 | - echo $lev3->getItem()->getValue() . " "; |
|
| 50 | + echo $lev3->getItem()->getValue()." "; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | |
| 42 | 42 | public function getCompareValue() |
| 43 | 43 | { |
| 44 | - return $this->lastName . "," . $this->firstName; |
|
| 44 | + return $this->lastName.",".$this->firstName; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -47,8 +47,8 @@ |
||
| 47 | 47 | echo "No entry found\n"; |
| 48 | 48 | } else { |
| 49 | 49 | $searchResultItem = $result->getItem(); |
| 50 | - echo $searchResultItem->getLastName() . ", " . $searchResultItem->getFirstName() . "\n"; |
|
| 51 | - echo $searchResultItem->getAddress() . "\n"; |
|
| 52 | - echo "Phone No.: " . $searchResultItem->getPhoneNumber() . "\n"; |
|
| 50 | + echo $searchResultItem->getLastName().", ".$searchResultItem->getFirstName()."\n"; |
|
| 51 | + echo $searchResultItem->getAddress()."\n"; |
|
| 52 | + echo "Phone No.: ".$searchResultItem->getPhoneNumber()."\n"; |
|
| 53 | 53 | } |
| 54 | -echo "Time to search with $dataStructure: " . sprintf("%1.2E", $time) . "\n"; |
|
| 54 | +echo "Time to search with $dataStructure: ".sprintf("%1.2E", $time)."\n"; |
|
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $tmp = $node; |
| 203 | 203 | $cmp = $node->getItem()->compareTo($item); |
| 204 | 204 | $child = null; |
| 205 | - switch($cmp) { |
|
| 205 | + switch ($cmp) { |
|
| 206 | 206 | case -1: |
| 207 | 207 | $child = $node->getRight(); |
| 208 | 208 | break; |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | } else { // left and right? |
| 243 | 243 | $tmp = $node->getRight(); //keep right in mind |
| 244 | 244 | $leftMostLeaf = $this->getLeftMostLeaf($tmp); // get the leftmost leaf of the right subtree |
| 245 | - $leftMostLeaf->setLeft($node->getLeft()); // append the left subtree to the leftmost leaf of the right subtree |
|
| 245 | + $leftMostLeaf->setLeft($node->getLeft()); // append the left subtree to the leftmost leaf of the right subtree |
|
| 246 | 246 | $node = $tmp; |
| 247 | 247 | } |
| 248 | 248 | } |
@@ -125,7 +125,7 @@ |
||
| 125 | 125 | $tmp = $node->getRight(); //keep right in mind |
| 126 | 126 | $this->rebalance($node->getItem(), $tmp); |
| 127 | 127 | $leftMostLeaf = $this->getLeftMostLeaf($tmp); // get the leftmost leaf of the right subtree |
| 128 | - $leftMostLeaf->setLeft($node->getLeft()); // append the left subtree to the leftmost leaf of the right subtree |
|
| 128 | + $leftMostLeaf->setLeft($node->getLeft()); // append the left subtree to the leftmost leaf of the right subtree |
|
| 129 | 129 | $node = $tmp; |
| 130 | 130 | } |
| 131 | 131 | } |