@@ 8-32 (lines=25) @@ | ||
5 | ||
6 | use Collections\Enumerable; |
|
7 | ||
8 | class LazySkipIterable implements Enumerable |
|
9 | { |
|
10 | use LazyIterableTrait; |
|
11 | ||
12 | /** |
|
13 | * @var Enumerable |
|
14 | */ |
|
15 | private $Enumerable; |
|
16 | ||
17 | /** |
|
18 | * @var int |
|
19 | */ |
|
20 | private $n; |
|
21 | ||
22 | public function __construct($Enumerable, $n) |
|
23 | { |
|
24 | $this->Enumerable = $Enumerable; |
|
25 | $this->n = $n; |
|
26 | } |
|
27 | ||
28 | public function getIterator() |
|
29 | { |
|
30 | return new LazySkipIterator($this->Enumerable->getIterator(), $this->n); |
|
31 | } |
|
32 | } |
|
33 | ||
34 |
@@ 7-31 (lines=25) @@ | ||
4 | ||
5 | use Collections\Enumerable; |
|
6 | ||
7 | class LazyTakeIterable implements Enumerable |
|
8 | { |
|
9 | use LazyIterableTrait; |
|
10 | ||
11 | /** |
|
12 | * @var Enumerable |
|
13 | */ |
|
14 | private $Enumerable; |
|
15 | ||
16 | /** |
|
17 | * @var int |
|
18 | */ |
|
19 | private $n; |
|
20 | ||
21 | public function __construct($Enumerable, $n) |
|
22 | { |
|
23 | $this->Enumerable = $Enumerable; |
|
24 | $this->n = $n; |
|
25 | } |
|
26 | ||
27 | public function getIterator() |
|
28 | { |
|
29 | return new LazyTakeIterator($this->Enumerable->getIterator(), $this->n); |
|
30 | } |
|
31 | } |
|
32 | ||
33 |