@@ 75-88 (lines=14) @@ | ||
72 | /** |
|
73 | * @inheritDoc |
|
74 | */ |
|
75 | public function filter(callable $callback) |
|
76 | { |
|
77 | list($sfa, $count) = $this->getSplFixedArrayAndSize(); |
|
78 | ||
79 | $newCount = 0; |
|
80 | foreach ($this as $elem) { |
|
81 | if ($callback($elem)) { |
|
82 | $sfa[$newCount++] = $elem; |
|
83 | } |
|
84 | } |
|
85 | ||
86 | $sfa->setSize($newCount); |
|
87 | return new static($sfa); |
|
88 | } |
|
89 | ||
90 | /** |
|
91 | * @inheritDoc |
|
@@ 139-148 (lines=10) @@ | ||
136 | /** |
|
137 | * @inheritDoc |
|
138 | */ |
|
139 | public function map(callable $callback) |
|
140 | { |
|
141 | list($sfa, $count) = $this->getSplFixedArrayAndSize(); |
|
142 | ||
143 | for ($i = 0; $i < $count; $i++) { |
|
144 | $sfa[$i] = $callback($this[$i], $i, $this); |
|
145 | } |
|
146 | ||
147 | return new static($sfa); |
|
148 | } |
|
149 | ||
150 | /** |
|
151 | * @inheritDoc |