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