| @@ 48-57 (lines=10) @@ | ||
| 45 | /** |
|
| 46 | * @inheritDoc |
|
| 47 | */ |
|
| 48 | public function map(callable $callback) |
|
| 49 | { |
|
| 50 | list($sfa, $count) = $this->getSplFixedArrayAndSize(); |
|
| 51 | ||
| 52 | for ($i = 0; $i < $count; $i++) { |
|
| 53 | $sfa[$i] = $callback($this[$i], $i, $this); |
|
| 54 | } |
|
| 55 | ||
| 56 | return new static($sfa); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @inheritDoc |
|
| @@ 74-87 (lines=14) @@ | ||
| 71 | /** |
|
| 72 | * @inheritDoc |
|
| 73 | */ |
|
| 74 | public function filter(callable $callback) |
|
| 75 | { |
|
| 76 | list($sfa, $count) = $this->getSplFixedArrayAndSize(); |
|
| 77 | ||
| 78 | $newCount = 0; |
|
| 79 | foreach ($this as $elem) { |
|
| 80 | if ($callback($elem)) { |
|
| 81 | $sfa[$newCount++] = $elem; |
|
| 82 | } |
|
| 83 | } |
|
| 84 | ||
| 85 | $sfa->setSize($newCount); |
|
| 86 | return new static($sfa); |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * @inheritDoc |
|