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


PHP Iterator::seek方法代碼示例

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


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

示例1: seek

 /**
  * Seeks to defined position. Does NOT throw {@link \OutOfBoundsException}.
  *
  * @param integer $position New position
  */
 public function seek($position)
 {
     if ($this->iterator instanceof \SeekableIterator) {
         try {
             $this->iterator->seek($position);
         } catch (\OutOfBoundsException $e) {
             // Skipped on purpose, I don't think it's necessary
             // If you'd like to have this exception throw, remove this try-catch and add to 'else' block
             // If (!$this->valid()) { throw new \OutOfBoundsException('Invalid seek position'); };
         }
     } else {
         $this->rewind();
         for ($i = 0; $i < $position; $i++) {
             $this->next();
         }
     }
 }
開發者ID:jyxo,項目名稱:php,代碼行數:22,代碼來源:MapIterator.php

示例2: seek

 /**
  * Seeks to a position.
  *
  * @param  int  $position
  * @return void
  * @throws \InvalidArgumentException when $position is not an integer.
  * @throws \OutOfBoundsException when the seek $position exeeds the traversable's length.
  */
 public function seek($position)
 {
     if (!$this->isInt($position)) {
         throw new InvalidArgumentException('Seek position must be an integer.');
     }
     $position = max(0, (int) $position);
     if ($this->length !== null && $this->length < $position) {
         throw new OutOfBoundsException('Invalid seek position (' . $position . ').');
     }
     if ($this->traversable()) {
         if ($this->traversable instanceof SeekableIterator) {
             $this->traversable->seek($position);
         } else {
             $this->traversable->rewind();
             for ($i = 0; $i < $position; $i++) {
                 $this->traversable->next();
             }
         }
     }
     $this->i = $position;
 }
開發者ID:CupOfTea696,項目名稱:Counter,代碼行數:29,代碼來源:Counter.php

示例3: getErrors

    /**
     * Prototype getErrors
     *
     * This method is not used. It is currently a prototype, a holder
     * for reverse engineering the actions and finding the errors
     * in each of the actions and creating them in the database associating
     * them with actions.
     *
     * @param  Iterator $it  The iterator to fetch the parameters from
     * @param  string   $methodName The original method name to parse.
     * @return mixed    Either an array of error or false.
     */
    private function getErrors($it, $methodName)
    {
        $error  = array();
        $i = 0;
        while ($it->valid()) {
            $it->next();
            $mainKey = $key = $it->key();
            $current = $it->current();

            if ((double)$current[0] == T_CONSTANT_ENCAPSED_STRING) {

                $error[$methodName][$key][$i] = array();
                $error[$methodName][$key][$i]['name'] = $current[1];

                while ($it->valid()) {
                    $it->next();
                    $current = $it->current();

                    if ((double)$current[0] == T_CONSTANT_ENCAPSED_STRING) {
                        $error[$methodName][$key]['message'] = $current[1];

                        while ($it->valid()) {

                            $it->next();
                            $current = $it->current();
                            if ((double)$current[0] == T_LNUMBER) {
                                $error[$methodName][$key]['code'] = $current[1];

                            }
                        }
                    } else {
                        if ($it->offsetExists($mainKey)) {
                            $it->seek($mainKey);
                        }
                    }
                }

                ++$i;
            } else {

            }
        }

        return !empty($error) ? $error : false;
    }
開發者ID:reith2004,項目名稱:frapi,代碼行數:57,代碼來源:ActionController.php


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