Skip to content

Commit 26687e4

Browse files
authored
Merge pull request #66 from simPod/fix-capacity
Fix shouldIncreaseCapacity() 2
2 parents 2c9c1aa + fda004d commit 26687e4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Traits/Capacity.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace Ds\Traits;
33

4+
use Ds\Deque;
5+
46
/**
57
* Common to structures that deal with an internal capacity. While none of the
68
* PHP implementations actually make use of a capacity, it's important to keep
@@ -104,6 +106,10 @@ protected function shouldDecreaseCapacity(): bool
104106
*/
105107
protected function shouldIncreaseCapacity(): bool
106108
{
107-
return count($this) > $this->capacity;
109+
if ($this instanceof Deque) {
110+
return count($this) > $this->capacity;
111+
}
112+
113+
return count($this) >= $this->capacity;
108114
}
109115
}

0 commit comments

Comments
 (0)