1 | <?php |
||
7 | trait SquaredCapacity |
||
8 | { |
||
9 | use Capacity; |
||
10 | |||
11 | /** |
||
12 | * Rounds an integer to the next power of two if not already a power of two. |
||
13 | * |
||
14 | * @param int $capacity |
||
15 | * |
||
16 | * @return int |
||
17 | */ |
||
18 | 213 | private function square(int $capacity): int |
|
22 | |||
23 | /** |
||
24 | * Ensures that enough memory is allocated for a specified capacity. This |
||
25 | * potentially reduces the number of reallocations as the size increases. |
||
26 | * |
||
27 | * @param int $capacity The number of values for which capacity should be |
||
28 | * allocated. Capacity will stay the same if this value |
||
29 | * is less than or equal to the current capacity. |
||
30 | */ |
||
31 | 30 | public function allocate(int $capacity) |
|
35 | |||
36 | /** |
||
37 | * Called when capacity should be increased to accommodate new values. |
||
38 | */ |
||
39 | 183 | protected function increaseCapacity() |
|
43 | } |
||
44 |