当前位置: 首页>>代码示例>>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;未经允许,请勿转载。