Conditions | 4 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function addNode(HuffmanNode $node) |
||
19 | { |
||
20 | if (\count($this->nodes) == 0) { |
||
21 | $this->nodes = [$node]; |
||
22 | |||
23 | return; |
||
24 | } |
||
25 | |||
26 | $index = 0; |
||
27 | while (isset($this->nodes[$index]) && $this->nodes[$index]->getWeight() < $node->getWeight()) { |
||
28 | ++$index; |
||
29 | } |
||
30 | array_splice($this->nodes, $index, 0, [$node]); |
||
31 | } |
||
60 |