@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace itertools; |
| 4 | 4 | |
| 5 | 5 | use RecursiveIterator; |
| 6 | -use IteratorIterator; |
|
| 7 | 6 | use EmptyIterator; |
| 8 | 7 | |
| 9 | 8 | |
@@ -71,6 +71,9 @@ discard block |
||
| 71 | 71 | return iterator_count($this); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | + /** |
|
| 75 | + * @param \Closure $callback |
|
| 76 | + */ |
|
| 74 | 77 | public function filter($callback) |
| 75 | 78 | { |
| 76 | 79 | return $this->callbackFilter($callback); |
@@ -96,6 +99,9 @@ discard block |
||
| 96 | 99 | } |
| 97 | 100 | } |
| 98 | 101 | |
| 102 | + /** |
|
| 103 | + * @param string $name |
|
| 104 | + */ |
|
| 99 | 105 | protected function pushIteratorByClassName($name, $arguments) |
| 100 | 106 | { |
| 101 | 107 | $reflector = new ReflectionClass($name); |
@@ -117,6 +123,9 @@ discard block |
||
| 117 | 123 | return $this->setInnerIterator(new ZipIterator(array_merge(array($this->getInnerIterator()), $iterables))); |
| 118 | 124 | } |
| 119 | 125 | |
| 126 | + /** |
|
| 127 | + * @param string $template |
|
| 128 | + */ |
|
| 120 | 129 | public function fixedLengthFormattedStringFromTemplate($template, array $nameMap = array(), array $options = array()) |
| 121 | 130 | { |
| 122 | 131 | return $this->setInnerIterator(FixedLengthFormattedStringIterator::newFromTemplate($this->getInnerIterator(), $template, $nameMap, $options)); |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace itertools; |
| 4 | 4 | |
| 5 | 5 | use InvalidArgumentException; |
| 6 | -use Exception; |
|
| 7 | 6 | |
| 8 | 7 | |
| 9 | 8 | class FixedLengthFormattedStringIterator extends MapIterator |
@@ -10,6 +10,9 @@ |
||
| 10 | 10 | |
| 11 | 11 | class FlippingIterator extends IteratorIterator |
| 12 | 12 | { |
| 13 | + /** |
|
| 14 | + * @param integer[] $iterator |
|
| 15 | + */ |
|
| 13 | 16 | public function __construct($iterator) |
| 14 | 17 | { |
| 15 | 18 | parent::__construct(IterUtil::asTraversable($iterator)); |
@@ -2,10 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace itertools; |
| 4 | 4 | |
| 5 | -use InvalidArgumentException; |
|
| 6 | 5 | use IteratorIterator; |
| 7 | -use Traversable; |
|
| 8 | -use ArrayIterator; |
|
| 9 | 6 | |
| 10 | 7 | |
| 11 | 8 | class FlippingIterator extends IteratorIterator |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use UnexpectedValueException; |
| 6 | 6 | use IteratorIterator; |
| 7 | -use ArrayIterator; |
|
| 8 | 7 | |
| 9 | 8 | |
| 10 | 9 | class ForkingIterator extends IteratorIterator |
@@ -79,6 +79,9 @@ |
||
| 79 | 79 | $this->keepLastEntries($this->maxHistorySize + 1); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | + /** |
|
| 83 | + * @param integer $count |
|
| 84 | + */ |
|
| 82 | 85 | protected function keepLastEntries($count) |
| 83 | 86 | { |
| 84 | 87 | while($this->history->count() > $count) { |
@@ -120,6 +120,10 @@ discard block |
||
| 120 | 120 | return true; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | + /** |
|
| 124 | + * @param \SplObjectStorage[] $iterable |
|
| 125 | + * @param string $method |
|
| 126 | + */ |
|
| 123 | 127 | public static function invoke($iterable, $method) |
| 124 | 128 | { |
| 125 | 129 | return new MapIterator($iterable, function($element) use ($method) { |
@@ -127,6 +131,9 @@ discard block |
||
| 127 | 131 | }); |
| 128 | 132 | } |
| 129 | 133 | |
| 134 | + /** |
|
| 135 | + * @param integer[] $iterable |
|
| 136 | + */ |
|
| 130 | 137 | public static function sum($iterable, $initialValue = 0) |
| 131 | 138 | { |
| 132 | 139 | self::assertIsCollection($iterable); |
@@ -137,6 +144,10 @@ discard block |
||
| 137 | 144 | return $sum; |
| 138 | 145 | } |
| 139 | 146 | |
| 147 | + /** |
|
| 148 | + * @param \Closure $callable |
|
| 149 | + * @param integer $initial |
|
| 150 | + */ |
|
| 140 | 151 | public static function iterator_reduce($iterable, $callable, $initial = null) |
| 141 | 152 | { |
| 142 | 153 | $returnValue = $initial; |
@@ -171,6 +182,9 @@ discard block |
||
| 171 | 182 | } |
| 172 | 183 | } |
| 173 | 184 | |
| 185 | + /** |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 174 | 188 | public static function getCurrentAndAdvance(&$iterable, $options = array()) |
| 175 | 189 | { |
| 176 | 190 | if(is_array($iterable)) { |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use UnexpectedValueException; |
| 6 | 6 | use ArrayIterator; |
| 7 | -use Exception; |
|
| 8 | 7 | use InvalidArgumentException; |
| 9 | 8 | use Iterator; |
| 10 | 9 | use IteratorAggregate; |
@@ -13,6 +13,11 @@ |
||
| 13 | 13 | protected $dir; |
| 14 | 14 | protected $lockNameMapper; |
| 15 | 15 | |
| 16 | + /** |
|
| 17 | + * @param RangeIterator $iterable |
|
| 18 | + * @param string $dir |
|
| 19 | + * @param \Closure $lockNameMapper |
|
| 20 | + */ |
|
| 16 | 21 | public function __construct($iterable, $dir, $lockNameMapper = null) |
| 17 | 22 | { |
| 18 | 23 | parent::__construct(IterUtil::asTraversable($iterable)); |
@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace itertools; |
| 4 | 4 | |
| 5 | -use ArrayIterator; |
|
| 6 | 5 | use Exception; |
| 7 | 6 | use IteratorIterator; |
| 8 | 7 | |
@@ -59,6 +59,9 @@ |
||
| 59 | 59 | return parent::current(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | + /** |
|
| 63 | + * @param integer $prefetchCount |
|
| 64 | + */ |
|
| 62 | 65 | public function prefetchUpTo($prefetchCount) |
| 63 | 66 | { |
| 64 | 67 | $this->autoRewind(); |