當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Iterator::key方法代碼示例

本文整理匯總了PHP中Iterator::key方法的典型用法代碼示例。如果您正苦於以下問題:PHP Iterator::key方法的具體用法?PHP Iterator::key怎麽用?PHP Iterator::key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Iterator的用法示例。


在下文中一共展示了Iterator::key方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: key

	public function key(){
		if ($this->innerHasItems === true){
			return $this->innerIterator->key();
		} else {
			return $this->defaultKey;
		}
	}
開發者ID:gpanda,項目名稱:security-scan-tool,代碼行數:7,代碼來源:DefaultIterator.php

示例2: key

 /**
  * Returns the key of the current value
  *
  * @return Mixed
  */
 public function key()
 {
     if (!isset($this->iterator)) {
         $this->getInnerIterator();
     }
     return $this->iterator->key();
 }
開發者ID:Nycto,項目名稱:Round-Eights,代碼行數:12,代碼來源:Defer.php

示例3: subscribe

 /**
  * @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);
         }
     });
 }
開發者ID:voryx,項目名稱:Rx.PHP,代碼行數:32,代碼來源:IteratorObservable.php

示例4: key

 public function key()
 {
     if (!$this->usingCache) {
         return $this->innerIterator->key();
     }
     return $this->position;
 }
開發者ID:wearebase,項目名稱:base-core,代碼行數:7,代碼來源:CachingIterator.php

示例5: key

 /**
  * @return Mixed|null Returns null if out of range
  */
 public function key()
 {
     if (!$this->baseIterator->valid()) {
         return null;
         // out of range
     }
     return $this->baseIterator->key();
 }
開發者ID:mangowi,項目名稱:mediawiki,代碼行數:11,代碼來源:MappedIterator.php

示例6: memo

 private function memo()
 {
     if (!$this->it->valid()) {
         return;
     }
     array_push($this->cache, array($this->it->key(), $this->it->current()));
     $this->cacheSize++;
 }
開發者ID:gunjiro,項目名稱:ginq,代碼行數:8,代碼來源:MemoizeIterator.php

示例7: fetch

 private function fetch()
 {
     if ($this->it->valid()) {
         $v = $this->it->current();
         $k = $this->it->key();
         $this->v = $this->valueSelector->select($v, $k);
         $this->k = $this->keySelector->select($v, $k);
     }
 }
開發者ID:gunjiro,項目名稱:ginq,代碼行數:9,代碼來源:SelectIterator.php

示例8: fetch

 private function fetch()
 {
     if ($this->it->valid()) {
         $this->v = $this->it->current();
         $this->k = $this->it->key();
         $fn = $this->fn;
         $fn($this->v, $this->k);
     }
 }
開發者ID:gunjiro,項目名稱:ginq,代碼行數:9,代碼來源:EachIterator.php

示例9: nextSatisfied

 private function nextSatisfied()
 {
     while ($this->it->valid()) {
         if ($this->predicate->predicate($this->it->current(), $this->it->key())) {
             break;
         } else {
             $this->it->next();
         }
     }
 }
開發者ID:gunjiro,項目名稱:ginq,代碼行數:10,代碼來源:WhereIterator.php

示例10: rewind

 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;
         }
     }
 }
開發者ID:gunjiro,項目名稱:ginq,代碼行數:12,代碼來源:DropWhileIterator.php

示例11: iterateAndCache

 /**
  * @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;
     }
 }
開發者ID:cubiche,項目名稱:cubiche,代碼行數:17,代碼來源:Cacheable.php

示例12: storeNext

 /**
  * Internally increments the iterator and saves the value
  *
  * @return Boolean Returns whether the iterator returned a valid value
  */
 private function storeNext()
 {
     if (!isset($this->iterator)) {
         return FALSE;
     } else {
         if ($this->iterator->valid()) {
             $this->cache[$this->internalOffset] = array($this->iterator->key(), $this->iterator->current());
             return TRUE;
         } else {
             unset($this->iterator);
             return FALSE;
         }
     }
 }
開發者ID:Nycto,項目名稱:Round-Eights,代碼行數:19,代碼來源:Cache.php

示例13: solveIntermediateOperationChain

 /**
  * @param \Iterator $operatorChain
  * @param \Iterator $input
  *
  * @return \ArrayIterator
  */
 private function solveIntermediateOperationChain(\Iterator $operatorChain, \Iterator $input)
 {
     $results = new \ArrayIterator();
     $input->rewind();
     $continueWIthNextItem = true;
     while ($input->valid() && $continueWIthNextItem) {
         $result = $input->current();
         $useResult = true;
         // do the whole intermediate operation chain for the current input
         $operatorChain->rewind();
         while ($operatorChain->valid() && $useResult) {
             /** @var IntermediateOperationInterface $current */
             $current = $operatorChain->current();
             // apply intermediate operations
             $result = $current->apply($result, $input->key(), $useResult, $returnedCanContinue);
             // track the continuation flags
             $continueWIthNextItem = $continueWIthNextItem && $returnedCanContinue;
             // iterate
             $operatorChain->next();
         }
         if ($useResult) {
             $results->append($result);
         }
         // goto next item
         $input->next();
     }
     return $results;
 }
開發者ID:peekandpoke,項目名稱:psi,代碼行數:34,代碼來源:DefaultOperationChainSolver.php

示例14: key

 /**
  * @inheritDoc
  */
 public function key()
 {
     if (!$this->acceptValidated) {
         $this->valid();
     }
     return $this->it->key();
 }
開發者ID:hunts,項目名稱:stream-php,代碼行數:10,代碼來源:Stream.php

示例15: fetchInner

 protected function fetchInner()
 {
     if ($this->valid()) {
         $this->v = $this->inner->current();
         $this->k = $this->inner->key();
     }
 }
開發者ID:gunjiro,項目名稱:ginq,代碼行數:7,代碼來源:SelectManyIterator.php


注:本文中的Iterator::key方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。