@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | /** |
235 | 235 | * Returns the minimum node from a given node in position X. |
236 | 236 | * |
237 | - * @param DataStructures\Trees\Nodes\BSTNode $node the start point. |
|
237 | + * @param BinaryNodeInterface $node the start point. |
|
238 | 238 | * @return DataStructures\Trees\Nodes\BSTNode|null the minimum node. |
239 | 239 | */ |
240 | 240 | private function getMinNode(BinaryNodeInterface $node = null) { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | /** |
253 | 253 | * Returns the maximum node from a given node in position X. |
254 | 254 | * |
255 | - * @param DataStructures\Trees\Nodes\BSTNode $node the start point. |
|
255 | + * @param BinaryNodeInterface $node the start point. |
|
256 | 256 | * @return DataStructures\Trees\Nodes\BSTNode|null the maximum node. |
257 | 257 | */ |
258 | 258 | private function getMaxNode(BinaryNodeInterface $node = null) { |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * Deletes the node with the minimum key and returns it. The most left and more bottom. |
272 | 272 | * |
273 | 273 | * @param DataStructures\Trees\Nodes\BSTNode|null if null takes the root. |
274 | - * @return DataStructures\Trees\Nodes\BSTNode|null the minimum node or |
|
274 | + * @return BinaryNodeInterface|null the minimum node or |
|
275 | 275 | * null if the tree is empty. |
276 | 276 | */ |
277 | 277 | public function deleteMin(BinaryNodeInterface $node = null) { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * Deletes the node with the maximum key and returns it. The most right and more bottom. |
288 | 288 | * |
289 | 289 | * @param DataStructures\Trees\Nodes\BSTNode|null if null takes the root. |
290 | - * @return DataStructures\Trees\Nodes\BSTNode|null the maximum node or |
|
290 | + * @return BinaryNodeInterface|null the maximum node or |
|
291 | 291 | * null if the tree is empty. |
292 | 292 | */ |
293 | 293 | public function deleteMax(BinaryNodeInterface $node = null) { |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * Deletes the node with the maximum key and returns it. The most right and more bottom. |
304 | 304 | * |
305 | 305 | * @param DataStructures\Trees\Nodes\BSTNode|null if null takes the root. |
306 | - * @return DataStructures\Trees\Nodes\BSTNode|null the maximum node or |
|
306 | + * @return BinaryNodeInterface|null the maximum node or |
|
307 | 307 | * null if the tree is empty. |
308 | 308 | */ |
309 | 309 | public function delete($key) { |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * that replaces the deleted node. Also decrease the size of tree. |
322 | 322 | * |
323 | 323 | * @param DataStructures\Trees\Nodes\BSTNode|null The node to be deleted. |
324 | - * @return the node that replaces the deleted. |
|
324 | + * @return DataStructures\Trees\Nodes\BSTNode|null node that replaces the deleted. |
|
325 | 325 | */ |
326 | 326 | protected function _delete(BinaryNodeInterface &$node) { |
327 | 327 | if($node !== null) { |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * Returns true if is leaf the node. |
410 | 410 | * |
411 | 411 | * @param DataStructures\Trees\Nodes\BSTNode|null $node default to null. |
412 | - * @return true if is leaf the node, is not null and their subtrees has no |
|
412 | + * @return boolean if is leaf the node, is not null and their subtrees has no |
|
413 | 413 | * pointers to successors. |
414 | 414 | */ |
415 | 415 | public function isLeaf($node) : bool { // BinaryTreeNode |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * also are called a root node. |
422 | 422 | * |
423 | 423 | * @param DataStructures\Trees\Nodes\BSTNode|null $node default to null. |
424 | - * @return true if is root the node, is not null and their subtrees has no |
|
424 | + * @return boolean if is root the node, is not null and their subtrees has no |
|
425 | 425 | * pointers to successors. |
426 | 426 | */ |
427 | 427 | public function isRoot($node) : bool { |
@@ -446,6 +446,7 @@ discard block |
||
446 | 446 | * @param DataStructures\Trees\Nodes\BSTNode|null $node. |
447 | 447 | * @param Callable|null $callback the callback function to apply to each |
448 | 448 | * node. |
449 | + * @param null|DataStructures\Trees\Nodes\BSTNode $node |
|
449 | 450 | */ |
450 | 451 | private function _preorder($node, Callable $callback = null) { |
451 | 452 | if($node === null) { |
@@ -476,6 +477,7 @@ discard block |
||
476 | 477 | * @param DataStructures\Trees\Nodes\BSTNode|null $node. |
477 | 478 | * @param Callable|null $callback the callback function to apply to each |
478 | 479 | * node. |
480 | + * @param null|DataStructures\Trees\Nodes\BSTNode $node |
|
479 | 481 | */ |
480 | 482 | private function _inorder($node, Callable $callback = null) { |
481 | 483 | if($node === null) { |
@@ -507,6 +509,7 @@ discard block |
||
507 | 509 | * @param DataStructures\Trees\Nodes\BSTNode|null $node. |
508 | 510 | * @param Callable|null $callback the callback function to apply to each |
509 | 511 | * node. |
512 | + * @param null|DataStructures\Trees\Nodes\BSTNode $node |
|
510 | 513 | */ |
511 | 514 | private function _postorder($node, Callable $callback = null) { |
512 | 515 | if($node === null) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * Returns the last node with O(1). |
139 | 139 | * |
140 | - * @return DataStructures\Lists\Nodes\DoublyLinkedListNode|null if the list is empty. |
|
140 | + * @return null|Node if the list is empty. |
|
141 | 141 | */ |
142 | 142 | public function searchLast() { |
143 | 143 | if($this->head === null) { |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * Generator for retrieve all nodes stored. |
151 | 151 | * |
152 | - * @return null if the head is null (or list is empty) |
|
152 | + * @return \Generator if the head is null (or list is empty) |
|
153 | 153 | */ |
154 | 154 | public function getAll() { |
155 | 155 | if($this->head === null) { |
@@ -80,7 +80,6 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * Add a new node in the specified index. |
82 | 82 | * |
83 | - * @param integer $index the position. |
|
84 | 83 | * @param mixed $data the data to be stored. |
85 | 84 | */ |
86 | 85 | private function insertEnd($data) { |
@@ -145,7 +144,7 @@ discard block |
||
145 | 144 | /** |
146 | 145 | * Returns the last node with O(1). |
147 | 146 | * |
148 | - * @return mixed null if the list is empty. |
|
147 | + * @return null|SimpleLinkedListNode null if the list is empty. |
|
149 | 148 | */ |
150 | 149 | protected function searchLast() { |
151 | 150 | if($this->head === null) { |
@@ -206,7 +205,7 @@ discard block |
||
206 | 205 | /** |
207 | 206 | * Generator for retrieve all nodes stored. |
208 | 207 | * |
209 | - * @return null if the head is null (or list is empty) |
|
208 | + * @return \Generator if the head is null (or list is empty) |
|
210 | 209 | */ |
211 | 210 | public function getAll() { |
212 | 211 | if($this->head === null) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param DataStructures\Trees\Nodes\AVLNode|null $left the left child node. |
33 | 33 | * @param DataStructures\Trees\Nodes\AVLNode|null $right the right child node. |
34 | 34 | * |
35 | - * @return DataStructures\Trees\Nodes\AVLNode the new node created. |
|
35 | + * @return AVLNode the new node created. |
|
36 | 36 | */ |
37 | 37 | public function createNode($key, $data, $parent = null, $left = null, $right = null) { |
38 | 38 | return new AVLNode($key, $data, $parent, $left, $right); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Does a right rotation. |
43 | 43 | * |
44 | - * @param DataStructures\Trees\Nodes\AVLNode $node The node to be |
|
44 | + * @param AVLNode $node The node to be |
|
45 | 45 | * rotated. |
46 | 46 | * @return DataStructures\Trees\Nodes\AVLNode |
47 | 47 | */ |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * Does a right rotation. |
76 | 76 | * |
77 | - * @param DataStructures\Trees\Nodes\AVLNode $node The node to be |
|
77 | + * @param AVLNode $node The node to be |
|
78 | 78 | * rotated. |
79 | 79 | * @return DataStructures\Trees\Nodes\AVLNode |
80 | 80 | */ |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * in the subtree root that detects the imbalance. |
113 | 113 | * Case Right-Left. |
114 | 114 | * |
115 | - * @param DataStructures\Trees\Nodes\AVLNode $node The node to be |
|
115 | + * @param AVLNode $node The node to be |
|
116 | 116 | * rotated. |
117 | 117 | * @return DataStructures\Trees\Nodes\AVLNode |
118 | 118 | */ |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * in the subtree root that detects the imbalance. |
128 | 128 | * Case Left-Right. |
129 | 129 | * |
130 | - * @param DataStructures\Trees\Nodes\AVLNode $node The node to be |
|
130 | + * @param AVLNode $node The node to be |
|
131 | 131 | * rotated. |
132 | 132 | * @return DataStructures\Trees\Nodes\AVLNode |
133 | 133 | */ |