public function __construct($innerIterator)
 {
     parent::__construct(IterUtil::asIterator($innerIterator));
     $this->lookAheads = new Queue();
     $this->skipAutoRewind = false;
     $this->skipNextNormalRewind = false;
 }
 public function __construct($innerIterator, $maxHistorySize = 1)
 {
     parent::__construct(IterUtil::asIterator($innerIterator));
     $this->history = new Queue();
     $this->maxHistorySize = $maxHistorySize;
     $this->hasStoredCurrent = false;
 }
Exemple #3
0
 /** @test */
 public function testAsIterator()
 {
     $this->assertTrue(IterUtil::asIterator(array()) instanceof ArrayIterator);
     $this->assertTrue(IterUtil::asIterator(new RangeIterator(1, 2)) instanceof RangeIterator);
     $this->assertTrue(IterUtil::asIterator(new Queue()) instanceof ArrayAccessIterator);
     $this->assertTrue(IterUtil::asIterator(new SimpleXMLElement('<root/>')) instanceof IteratorIterator);
 }
 public function __construct($iterator, $callback)
 {
     parent::__construct(IterUtil::asIterator($iterator));
     if (!is_callable($callback)) {
         throw new InvalidArgumentException('No valid callback provided');
     }
     $this->callback = $callback;
 }
 public function __construct($input, array $options = array())
 {
     if (is_string($input)) {
         $input = new ArrayIterator(preg_split('/\\r\\n|\\n|\\r/', $input));
     }
     $this->lines = IterUtil::asIterator($input);
     $this->lines->rewind();
     parent::__construct($options);
 }
Exemple #6
0
 public function __construct(array $iterators)
 {
     if (count($iterators) == 0) {
         throw new InvalidArgumentException('Cannot construct a ZipIterator from an empty array of iterators');
     }
     $this->iterators = array();
     foreach ($iterators as $iterator) {
         $this->iterators[] = IterUtil::asIterator($iterator);
     }
 }
Exemple #7
0
 public function setNextValidSubIterator()
 {
     while ($this->iterator->valid()) {
         $this->currentSubIterator = IterUtil::asIterator($this->iterator->current());
         $this->currentSubIterator->rewind();
         if ($this->currentSubIterator->valid()) {
             return;
         }
         $this->iterator->next();
     }
     $this->currentSubIterator = new EmptyIterator();
 }
 public function __construct($innerIterable, $comparator = null)
 {
     parent::__construct(IterUtil::asIterator($innerIterable));
     if (null === $comparator) {
         $comparator = function ($value) {
             return $value;
         };
     }
     if (!is_callable($comparator)) {
         throw new InvalidArgumentException('Comparator must be a callable');
     }
     $this->comparator = $comparator;
     $this->groupIndex = 0;
 }
 public function __construct($startNodes, $getChildrenCallback)
 {
     parent::__construct(IterUtil::asIterator($startNodes));
     $this->getChildrenCallback = $getChildrenCallback;
 }
 public function __construct($iterator)
 {
     parent::__construct(IterUtil::asIterator($iterator));
 }
 public function __construct($innerIterator)
 {
     parent::__construct(IterUtil::asIterator($innerIterator));
     $this->currentUpToDate = false;
     $this->validUpToDate = false;
 }
 public function __construct($innerIterator)
 {
     $this->innerIterator = IterUtil::asIterator($innerIterator);
 }