/**
  * Lazily append the next iterator to the chain
  */
 private function lazyAppend()
 {
     if (!parent::valid() and $this->iterators->valid()) {
         $this->append($this->iterators->current());
         $this->iterators->next();
     }
 }
 public function next()
 {
     $this->it->next();
     if ($this->currentLen !== 0) {
         --$this->currentLen;
     }
 }
Beispiel #3
0
 /**
  * @param ObserverInterface $observer
  * @param SchedulerInterface|null $scheduler
  * @return \Rx\Disposable\CompositeDisposable|\Rx\DisposableInterface
  */
 public function subscribe(ObserverInterface $observer, SchedulerInterface $scheduler = null)
 {
     $scheduler = $scheduler ?: new ImmediateScheduler();
     $key = 0;
     return $scheduler->scheduleRecursive(function ($reschedule) use(&$observer, &$key) {
         try {
             //HHVM requires you to call next() before current()
             if (defined('HHVM_VERSION')) {
                 $this->items->next();
                 $key = $this->items->key();
             }
             if (null === $key) {
                 $observer->onCompleted();
                 return;
             }
             $current = $this->items->current();
             $observer->onNext($current);
             if (!defined('HHVM_VERSION')) {
                 $this->items->next();
                 $key = $this->items->key();
             }
             $reschedule();
         } catch (\Exception $e) {
             $observer->onError($e);
         }
     });
 }
 public function next()
 {
     if (!$this->usingCache) {
         $this->innerIterator->next();
     }
     ++$this->position;
 }
Beispiel #5
0
 public function next()
 {
     $this->i++;
     if ($this->valid()) {
         $this->it->next();
     }
 }
 public function next()
 {
     $this->projectionNeeded = true;
     unset($this->current);
     unset($this->currentKey);
     return $this->innerIterator->next();
 }
 public function next()
 {
     parent::next();
     if (!parent::valid()) {
         $this->source->next();
     }
 }
Beispiel #8
0
 public function next()
 {
     while (true) {
         $this->it->next();
         if ($this->it->valid()) {
             if ($this->fetch()) {
                 break;
             }
         } else {
             if ($this->it === $this->it0) {
                 $this->it = $this->it1;
                 $this->it->rewind();
                 if ($this->it->valid()) {
                     if ($this->fetch()) {
                         break;
                     }
                 } else {
                     break;
                 }
             } else {
                 break;
             }
         }
     }
 }
Beispiel #9
0
 /**
  * {@inheritdoc}
  */
 public function next()
 {
     $this->neighbour->next();
     if (!$this->neighbour->valid()) {
         $this->neighbour->rewind();
         parent::next();
     }
 }
 public function next()
 {
     $this->currentIt->next();
     if ($this->state === 1 && !$this->currentIt->valid()) {
         $this->currentIt = $this->it2;
         $this->state = 2;
     }
 }
Beispiel #11
0
 public function next()
 {
     $this->i++;
     if ($this->cacheSize == $this->i) {
         $this->it->next();
         $this->memo();
     }
 }
Beispiel #12
0
 public function next()
 {
     $this->i++;
     $this->it->next();
     if ($this->it === $this->it0 && !$this->it->valid()) {
         $this->it = $this->it1;
     }
 }
 public function next()
 {
     $this->points->next();
     if (!$this->points->valid()) {
         $this->series->next();
         $serie = $this->series->current();
         $this->points = new \ArrayIterator($serie ? $serie['values'] : []);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function next()
 {
     $this->key++;
     $this->getCurrentIterator()->next();
     if (!$this->currentIterator->valid()) {
         $this->mainIterator->next();
         $this->currentIterator = $this->mainIterator->current();
     }
 }
Beispiel #15
0
 public function next()
 {
     $this->i++;
     $this->it->next();
     $v = $this->it->valid();
     if (!$v) {
         $this->it->rewind();
     }
 }
Beispiel #16
0
 public function next()
 {
     $this->inner->next();
     if (!$this->inner->valid()) {
         $this->outer->next();
         $this->fetchOuter();
     }
     $this->fetchInner();
 }
 public function fetch($fetchMode = null)
 {
     if (!$this->currentIterator) {
         $this->currentIterator = $this->getIterator();
     }
     $data = $this->currentIterator->current();
     $this->currentIterator->next();
     return $data;
 }
Beispiel #18
0
 public function next()
 {
     if ($this->skipNext === true) {
         $this->skipNext = false;
         return;
     }
     $this->iterator->next();
     $this->stack->push($this->iterator->current());
 }
 /**
  * @param $limit
  * @return Resource[]
  */
 public function collect($limit = -1)
 {
     $resources = array();
     while ($limit && $this->iterator->valid()) {
         $resources[] = $this->iterator->current();
         $this->iterator->next();
         $limit--;
     }
     return $resources;
 }
 /**
  * @return string
  */
 public function dir_readdir()
 {
     if ($this->iterator->valid()) {
         $result = $this->iterator->current();
         $this->iterator->next();
         return $result;
     } else {
         return false;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function next()
 {
     if ($this->subIterate && $this->subIterate->valid()) {
         $this->subIterate->next();
     }
     if (!$this->subIterate->valid()) {
         $this->toIterate->next();
         $this->initializeSubIterate();
     }
     ++$this->position;
 }
Beispiel #22
0
 public function rewind()
 {
     $this->i = 0;
     $this->it->rewind();
     for ($j = 0; $j < $this->n; $j++) {
         if ($this->it->valid()) {
             $this->it->next();
         } else {
             break;
         }
     }
 }
Beispiel #23
0
 public function rewind()
 {
     $this->i = 0;
     $this->it->rewind();
     while ($this->it->valid()) {
         if ($this->predicate->predicate($this->it->current(), $this->it->key())) {
             $this->it->next();
         } else {
             break;
         }
     }
 }
Beispiel #24
0
 public function next()
 {
     $this->inner->next();
     while (!$this->inner->valid()) {
         $this->outer->next();
         $this->fetchOuter();
         if ($this->inner === null) {
             break;
         }
     }
     $this->fetchInner();
 }
Beispiel #25
0
 public function next()
 {
     while (true) {
         $this->it->next();
         if ($this->it->valid()) {
             if ($this->fetch()) {
                 break;
             }
         } else {
             break;
         }
     }
 }
Beispiel #26
0
 /**
  * @inheritdoc
  */
 public function current()
 {
     $current = $this->delegatorReader->current();
     if (!$current) {
         $this->iterator->next();
         if (!$this->iterator->valid()) {
             return false;
         }
         $resource = $this->convertResource($this->resource, $this->iterator->current());
         $this->delegatorReader->open($resource);
         return $this->current();
     }
     return $current;
 }
Beispiel #27
0
 /**
  * @return Generator
  */
 private function iterateAndCache()
 {
     foreach ($this->cache as $key => $value) {
         (yield $key => $value);
     }
     if ($this->innerIterator !== null) {
         while ($this->innerIterator->valid()) {
             $this->cache[$this->innerIterator->key()] = $this->innerIterator->current();
             (yield $this->innerIterator->key() => $this->innerIterator->current());
             $this->innerIterator->next();
         }
         $this->innerIterator = null;
     }
 }
Beispiel #28
0
 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Return the current element
  * @link http://php.net/manual/en/iterator.current.php
  * @return array Can return any type.
  */
 public function current()
 {
     if ($this->currentGroup == null) {
         $left = $this->groupSize;
         $this->currentGroup = array();
         while ($this->innerIterator->valid()) {
             if ($left-- <= 0) {
                 break;
             }
             $this->currentGroup[] = $this->innerIterator->current();
             $this->innerIterator->next();
         }
     }
     return $this->currentGroup;
 }
 public function read()
 {
     if (!isset($this->iterator)) {
         $this->initializeIterator();
     }
     if (!$this->iterator->valid()) {
         return null;
     }
     $current = $this->iterator->current();
     if ($this->stepExecution) {
         $this->stepExecution->incrementSummaryInfo('read');
     }
     $this->iterator->next();
     return $current;
 }
 public function read()
 {
     if (!isset($this->iterator)) {
         $this->initializeIterator();
     }
     if (!$this->iterator->valid()) {
         return null;
     }
     $current = $this->iterator->current();
     if ($this->stepExecution) {
         $this->stepExecution->incrementSummaryInfo('read');
     }
     $this->iterator->next();
     return $this->convertNumericIdentifierToString($current);
 }