Skip to content

Commit 56e0f7c

Browse files
authored
Merge pull request #76 from simPod/init-capacity
Fix handling of initial capacity for Deque
2 parents dd55a2b + 93e4cfc commit 56e0f7c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Traits/GenericSequence.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public function __construct(iterable $values = [])
3131
foreach ($values as $value) {
3232
$this->push($value);
3333
}
34+
35+
$this->capacity = max(
36+
$values === null ? 0 : count($values),
37+
$this::MIN_CAPACITY
38+
);
3439
}
3540

3641
/**

0 commit comments

Comments
 (0)