Skip to content

Commit 43da343

Browse files
committed
Update NaryNode and the way nodes are added.
1 parent 5712df1 commit 43da343

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Node/NaryNode.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ public function __construct(int $capacity = 0, NodeInterface $parent = null, Tra
4343
*/
4444
public function add(NodeInterface ...$nodes): NodeInterface
4545
{
46-
foreach ($nodes as $node) {
47-
$capacity = $this->capacity();
46+
$capacity = $this->capacity();
47+
48+
if (0 === $capacity) {
49+
return parent::add(...$nodes);
50+
}
4851

49-
if (0 === $capacity || ($this->degree() < $capacity)) {
52+
foreach ($nodes as $node) {
53+
if ($this->degree() < $capacity) {
5054
parent::add($node);
5155

5256
continue;

0 commit comments

Comments
 (0)