| @@ 5-46 (lines=42) @@ | ||
| 2 | ||
| 3 | namespace Collections\Iterator; |
|
| 4 | ||
| 5 | class LazyKeysIterator implements \Iterator |
|
| 6 | { |
|
| 7 | /** |
|
| 8 | * @var \Iterator |
|
| 9 | */ |
|
| 10 | private $it; |
|
| 11 | ||
| 12 | public function __construct($it) |
|
| 13 | { |
|
| 14 | $this->it = $it; |
|
| 15 | } |
|
| 16 | ||
| 17 | public function __clone() |
|
| 18 | { |
|
| 19 | $this->it = clone $this->it; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function rewind() |
|
| 23 | { |
|
| 24 | $this->it->rewind(); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function valid() |
|
| 28 | { |
|
| 29 | return $this->it->valid(); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function next() |
|
| 33 | { |
|
| 34 | $this->it->next(); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function key() |
|
| 38 | { |
|
| 39 | return null; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function current() |
|
| 43 | { |
|
| 44 | return $this->it->key(); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 5-46 (lines=42) @@ | ||
| 2 | ||
| 3 | namespace Collections\Iterator; |
|
| 4 | ||
| 5 | class LazyValuesIterator implements \Iterator |
|
| 6 | { |
|
| 7 | /** |
|
| 8 | * @var \Iterator |
|
| 9 | */ |
|
| 10 | private $it; |
|
| 11 | ||
| 12 | public function __construct($it) |
|
| 13 | { |
|
| 14 | $this->it = $it; |
|
| 15 | } |
|
| 16 | ||
| 17 | public function __clone() |
|
| 18 | { |
|
| 19 | $this->it = clone $this->it; |
|
| 20 | } |
|
| 21 | ||
| 22 | public function rewind() |
|
| 23 | { |
|
| 24 | $this->it->rewind(); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function valid() |
|
| 28 | { |
|
| 29 | return $this->it->valid(); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function next() |
|
| 33 | { |
|
| 34 | $this->it->next(); |
|
| 35 | } |
|
| 36 | ||
| 37 | public function key() |
|
| 38 | { |
|
| 39 | return null; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function current() |
|
| 43 | { |
|
| 44 | return $this->it->current(); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||