当前位置: 首页>>代码示例>>PHP>>正文


PHP Iterator类代码示例

本文整理汇总了PHP中Iterator的典型用法代码示例。如果您正苦于以下问题:PHP Iterator类的具体用法?PHP Iterator怎么用?PHP Iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkStemmer

 protected function checkStemmer(Stemmer $stemmer, \Iterator $words, \Iterator $stems)
 {
     foreach ($words as $word) {
         $stem = $stems->current();
         $this->assertEquals($stemmer->stem($word), $stem, "The stem for '{$word}' should be '{$stem}' not '{$stemmer->stem($word)}'");
         $stems->next();
     }
 }
开发者ID:LewisGet,项目名称:php-nlp-tools,代码行数:8,代码来源:StemmerTestBase.php

示例2: rewind

 /**
  * {@inheritdoc}
  */
 public function rewind()
 {
     if (!$this->iterator) {
         $this->initIterator();
     }
     $this->iterator->rewind();
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:10,代码来源:TemplateIterator.php

示例3: getCurrentIterator

 private function getCurrentIterator()
 {
     if (null === $this->currentIterator) {
         $this->currentIterator = $this->mainIterator->current();
     }
     return $this->currentIterator;
 }
开发者ID:adrienbrault,项目名称:pagerfanta-iterator,代码行数:7,代码来源:IteratorIterator.php

示例4: doMatch

 /**
  * {@inheritdoc}
  */
 protected function doMatch($name, \Iterator $subject, $expected, $elementNumber)
 {
     $actual = $subject->current();
     if ($expected !== $actual) {
         throw new FailureException(sprintf('Element #%d was expected to be %s, but %s was given.', $elementNumber, $this->presenter->presentValue($expected), $this->presenter->presentValue($actual)));
     }
 }
开发者ID:pamil,项目名称:phpspec-generator-extension,代码行数:10,代码来源:GenerateValuesMatcher.php

示例5: rewind

 /**
  * Rewind the Iterator to the first element.
  *
  * @link  http://php.net/manual/en/iterator.rewind.php
  * @since 5.0.0
  */
 public function rewind()
 {
     if (null === $this->iterator) {
         throw new \LogicException('Missing internal iterator.');
     }
     $this->iterator->rewind();
 }
开发者ID:rayrutjes,项目名称:php-geteventstore-client,代码行数:13,代码来源:InternalIteratorTrait.php

示例6: advanceElementIterator

 private function advanceElementIterator(\Iterator $element)
 {
     $element->next();
     if (!$element->valid()) {
         next($this->fields);
     }
 }
开发者ID:PeeHaa,项目名称:Artax,代码行数:7,代码来源:MultipartIterator.php

示例7: rewind

 /**
  * {@inheritdoc}
  */
 public function rewind()
 {
     if (!$this->iterableResult) {
         $this->iterableResult = new \ArrayIterator($this->getDataFromService());
     }
     $this->iterableResult->rewind();
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:10,代码来源:ServiceReader.php

示例8: indexDatabase

 /**
  * Builds the index for the given collection
  *
  * @param DatabaseInterface|\Iterator $database
  * @return $this
  */
 public function indexDatabase($database)
 {
     // Clear the map
     $this->map = array();
     /** @var SplFixedArray $collection */
     $collection = null;
     if ($database instanceof DatabaseRawDataInterface) {
         $collection = $database->getRawData();
     }
     if ($database instanceof SplFixedArray) {
         // Use the fixed array as is
     } elseif (is_array($database)) {
         $collection = SplFixedArray::fromArray($database);
     } elseif ($database instanceof \Iterator) {
         $collection = SplFixedArray::fromArray(iterator_to_array($database));
     } else {
         throw new InvalidIndexException(sprintf('Can not build index of argument of type %s', is_object($database) ? get_class($database) : gettype($database)));
     }
     $position = 0;
     $count = $collection->getSize();
     if ($count > 0) {
         do {
             $tempEntry = DocumentUtility::assertDocumentIdentifier($database[$position]);
             $this->addEntryWithPosition($tempEntry, $position);
         } while (++$position < $count);
     }
 }
开发者ID:marviktintor,项目名称:pos-1,代码行数:33,代码来源:Key.php

示例9: foo

/**
 *
 */
function foo(Iterator $param)
{
    if ($param->valid()) {
        echo 'valid';
    } else {
        echo 'invalid';
    }
}
开发者ID:robo47,项目名称:php-manipulator,代码行数:11,代码来源:input2.php

示例10: valid

	public function valid(){
		if ($this->isFirstValidCall === true){
			$this->innerHasItems = $this->innerIterator->valid();
			$this->isFirstValidCall = false;
			return true;
		}
		return $this->innerIterator->valid();
	}
开发者ID:gpanda,项目名称:security-scan-tool,代码行数:8,代码来源:DefaultIterator.php

示例11: baa

 public static function baa(Iterator $param)
 {
     if ($param->valid()) {
         echo 'valid';
     } else {
         echo 'invalid';
     }
 }
开发者ID:robo47,项目名称:php-manipulator,代码行数:8,代码来源:input3.php

示例12: getIterator

 /**
  * {@inheritdoc}
  */
 public function getIterator()
 {
     if ($this->sortedIterator === null) {
         $this->sortedIterator = new \ArrayIterator($this->enumerable()->toArray(true));
         $this->sortedIterator->uasort($this->comparator());
     }
     return $this->sortedIterator;
 }
开发者ID:cubiche,项目名称:cubiche,代码行数:11,代码来源:SortedEnumerable.php

示例13: initializeIterator

 /**
  * Initializes the iterator
  */
 protected function initializeIterator()
 {
     $this->iterator = $this->createIterator();
     if ($this->batchMode) {
         $this->iterator = new \ArrayIterator(array(iterator_to_array($this->iterator)));
     }
     $this->iterator->rewind();
 }
开发者ID:antoineguigan,项目名称:ExcelConnectorBundle,代码行数:11,代码来源:AbstractIteratorReader.php

示例14: fetch

 /**
  * @param \Iterator $cursor
  *
  * @return array
  */
 public function fetch(\Iterator $cursor)
 {
     $data = [];
     if ($cursor->valid()) {
         $data = $cursor->current();
         $cursor->next();
     }
     return $data;
 }
开发者ID:respect,项目名称:structural,代码行数:14,代码来源:Driver.php

示例15: lazyAppend

 /**
  * 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();
     }
 }
开发者ID:indigophp,项目名称:iterators,代码行数:10,代码来源:LazyAppendIterator.php


注:本文中的Iterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。