Skip to content

Commit

Permalink
Update NaryNode and the way nodes are added.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Jun 12, 2019
1 parent 5712df1 commit 43da343
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Node/NaryNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ public function __construct(int $capacity = 0, NodeInterface $parent = null, Tra
*/
public function add(NodeInterface ...$nodes): NodeInterface
{
foreach ($nodes as $node) {
$capacity = $this->capacity();
$capacity = $this->capacity();

if (0 === $capacity) {
return parent::add(...$nodes);
}

if (0 === $capacity || ($this->degree() < $capacity)) {
foreach ($nodes as $node) {
if ($this->degree() < $capacity) {
parent::add($node);

continue;
Expand Down

0 comments on commit 43da343

Please sign in to comment.