| @@ 34-41 (lines=8) @@ | ||
| 31 | /** |
|
| 32 | * @return Traversable |
|
| 33 | */ |
|
| 34 | public function getIterator(): Traversable |
|
| 35 | { |
|
| 36 | if (!$this->isSorted) { |
|
| 37 | usort($this->list, [$this, 'compare']); |
|
| 38 | $this->isSorted = true; |
|
| 39 | } |
|
| 40 | return new ArrayIterator($this->list); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @param Box $item |
|
| @@ 42-49 (lines=8) @@ | ||
| 39 | /** |
|
| 40 | * @return Item |
|
| 41 | */ |
|
| 42 | public function extract(): Item |
|
| 43 | { |
|
| 44 | if (!$this->isSorted) { |
|
| 45 | usort($this->list, [$this, 'compare']); |
|
| 46 | $this->isSorted = true; |
|
| 47 | } |
|
| 48 | return array_shift($this->list); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @return Item |
|
| @@ 54-62 (lines=9) @@ | ||
| 51 | /** |
|
| 52 | * @return Item |
|
| 53 | */ |
|
| 54 | public function top(): Item |
|
| 55 | { |
|
| 56 | if (!$this->isSorted) { |
|
| 57 | usort($this->list, [$this, 'compare']); |
|
| 58 | $this->isSorted = true; |
|
| 59 | } |
|
| 60 | $temp = $this->list; |
|
| 61 | return reset($temp); |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * @return Traversable |
|
| @@ 67-74 (lines=8) @@ | ||
| 64 | /** |
|
| 65 | * @return Traversable |
|
| 66 | */ |
|
| 67 | public function getIterator(): Traversable |
|
| 68 | { |
|
| 69 | if (!$this->isSorted) { |
|
| 70 | usort($this->list, [$this, 'compare']); |
|
| 71 | $this->isSorted = true; |
|
| 72 | } |
|
| 73 | return new ArrayIterator($this->list); |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Number of items in list |
|
| @@ 41-48 (lines=8) @@ | ||
| 38 | /** |
|
| 39 | * @return Traversable |
|
| 40 | */ |
|
| 41 | public function getIterator(): Traversable |
|
| 42 | { |
|
| 43 | if (!$this->isSorted) { |
|
| 44 | usort($this->list, [$this, 'compare']); |
|
| 45 | $this->isSorted = true; |
|
| 46 | } |
|
| 47 | return new ArrayIterator($this->list); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * Number of items in list |
|
| @@ 78-85 (lines=8) @@ | ||
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | public function top(): PackedBox |
|
| 79 | { |
|
| 80 | if (!$this->isSorted) { |
|
| 81 | usort($this->list, [$this, 'compare']); |
|
| 82 | $this->isSorted = true; |
|
| 83 | } |
|
| 84 | return reset($this->list); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * @param PackedBox $boxA |
|
| @@ 42-49 (lines=8) @@ | ||
| 39 | /** |
|
| 40 | * @return Traversable |
|
| 41 | */ |
|
| 42 | public function getIterator(): Traversable |
|
| 43 | { |
|
| 44 | if (!$this->isSorted) { |
|
| 45 | usort($this->list, [$this, 'compare']); |
|
| 46 | $this->isSorted = true; |
|
| 47 | } |
|
| 48 | return new ArrayIterator($this->list); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Number of items in list |
|