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


PHP Iterator::getRawData方法代码示例

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


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

示例1: 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

示例2: 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();
     } elseif ($database instanceof SplFixedArray) {
         $collection = $database;
     } 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();
     $tempMap = array();
     if ($count > 0) {
         $collectionContainsDocumentObjects = $collection[0] instanceof DocumentInterface;
         do {
             $entry = $collection[$position];
             if ($collectionContainsDocumentObjects) {
                 $key = DocumentUtility::assertDocumentIdentifier($entry)->getId();
             } else {
                 $key = DocumentUtility::getIdentifierForDocument($entry);
             }
             //				DebugUtility::var_dump('Index', $key);
             if (isset($tempMap[$key])) {
                 throw new DuplicateEntryException(sprintf('Duplicate entry \'%s\' for identifier', $key), 1415046937);
             }
             $tempMap[$key] = $position;
         } while (++$position < $count);
     }
     $this->map = $tempMap;
 }
开发者ID:marviktintor,项目名称:pos-1,代码行数:44,代码来源:IdentifierIndex.php


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