| Total Complexity | 3 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Mbh\Traits; |
||
| 14 | trait SquaredCapacity |
||
| 15 | { |
||
| 16 | use Capacity; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @inheritDoc |
||
| 20 | */ |
||
| 21 | protected $capacity = self::MIN_CAPACITY; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Rounds an integer to the next power of two if not already a power of two. |
||
| 25 | * |
||
| 26 | * @param int $capacity |
||
| 27 | * |
||
| 28 | * @return int |
||
| 29 | */ |
||
| 30 | private function square(int $capacity): int |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Ensures that enough memory is allocated for a specified capacity. This |
||
| 37 | * potentially reduces the number of reallocations as the size increases. |
||
| 38 | * |
||
| 39 | * @param int $capacity The number of values for which capacity should be |
||
| 40 | * allocated. Capacity will stay the same if this value |
||
| 41 | * is less than or equal to the current capacity. |
||
| 42 | */ |
||
| 43 | public function allocate(int $capacity) |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Called when capacity should be increased to accommodate new values. |
||
| 50 | */ |
||
| 51 | protected function increaseCapacity() |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Gets the size of the array. |
||
| 58 | * |
||
| 59 | * @return int |
||
| 60 | */ |
||
| 61 | abstract protected function count(): int; |
||
| 62 | } |
||
| 63 |