當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。