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


PHP SplStack::count方法代碼示例

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


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

示例1: getLastEntry

 /**
  * {@inheritdoc}
  */
 public function getLastEntry() : EntryInterface
 {
     if (0 === $this->stack->count()) {
         throw new \RuntimeException('Trace empty');
     }
     return $this->stack->top();
 }
開發者ID:TeknooSoftware,項目名稱:states-life-cycle,代碼行數:10,代碼來源:Trace.php

示例2: endGroup

 public function endGroup()
 {
     if ($this->predicateStack->count() <= 1) {
         throw new \BadMethodCallException('Invalid operation: Not in a condition group.');
     }
     $this->predicateStack->pop();
     return $this;
 }
開發者ID:aztech-dev,項目名稱:phraseanet-bundle,代碼行數:8,代碼來源:PredicateBuilder.php

示例3: processSystemVar

 /**
  * A hook to the $system special variable. Returns the
  * compiled PHP code for the call.
  *
  * @internal
  * @param array $namespace The namespace to parse
  * @return string
  */
 public function processSystemVar($opt)
 {
     if ($this->_stack->count() == 0) {
         throw new Opt_SysVariableInvalidUse_Exception('$' . implode('.', $opt), 'components');
     }
     return $this->_stack->top() . '->get(\'' . $opt[2] . '\')';
 }
開發者ID:OPL,項目名稱:Open-Power-Template,代碼行數:15,代碼來源:Component.php

示例4: topOfStack

 /**
  * Returns the form stack head element. If the stack is empty,
  * the method returns NULL.
  *
  * @internal
  * @static
  * @return Opf_Form
  */
 public static function topOfStack()
 {
     if (self::$_stack === null) {
         self::$_stack = new SplStack();
     }
     if (self::$_stack->count() == 0) {
         return null;
     }
     return self::$_stack->top();
 }
開發者ID:OPL,項目名稱:Open-Power-Forms,代碼行數:18,代碼來源:Form.php

示例5: SplQueue

 function infix_to_rpn($tokens)
 {
     $out_q = new SplQueue();
     $stack = new SplStack();
     $index = 0;
     while (count($tokens) > $index) {
         $t = $tokens[$index];
         switch ($t) {
             case !in_array($t, self::operators_dictionary):
                 $out_q->enqueue($t);
                 break;
             case $t == "not":
             case $t == "and":
             case $t == "or":
                 $stack->push($t);
                 break;
             case $t == "(":
                 $stack->push($t);
                 break;
             case $t == ")":
                 while ($stack->top() != "(") {
                     $out_q->enqueue($stack->pop());
                 }
                 $stack->pop();
                 if ($stack->count() > 0 && $stack->top() == "not") {
                     $out_q->enqueue($stack->pop());
                 }
                 break;
             default:
                 break;
         }
         ++$index;
     }
     while ($stack->count() > 0) {
         $out_q->enqueue($stack->pop());
     }
     $reversed_q = array();
     foreach ($out_q as $value) {
         $reversed_q[] = $value;
     }
     return array_reverse($reversed_q);
 }
開發者ID:rotman,項目名稱:searchEngine,代碼行數:42,代碼來源:parser.class.php

示例6: _removeSection

 /**
  * Removes the specified section from the stack. The name
  * is provided to check, if the order of the closing is
  * valid.
  *
  * @static
  * @internal
  * @param String $name The section name.
  */
 private static function _removeSection($name)
 {
     if (self::$_stack->count() == 0) {
         throw new Opt_ObjectNotExists_Exception('section', $name);
     }
     $name2 = self::$_stack->pop();
     if ($name != $name2) {
         throw new Opl_Debug_Generic_Exception('OPT: Invalid section name thrown from the stack. Expected: ' . $name . '; Actual: ' . $name2);
     }
     unset(self::$_sections[$name]);
 }
開發者ID:OPL,項目名稱:Open-Power-Template,代碼行數:20,代碼來源:BaseSection.php

示例7: solve

 private function solve($formula)
 {
     $findSubFormula = false;
     $stringStart = 0;
     $stringLength = 0;
     $stack = new \SplStack();
     $subFormulas = [];
     for ($i = 0; $i < strlen($formula); $i++) {
         $char = $formula[$i];
         if ($this->isBracketOpen($char)) {
             if ($findSubFormula == false && $stack->count() == 0) {
                 $stringStart = $i;
             }
             $stack->push(1);
             $findSubFormula = true;
         }
         if ($findSubFormula) {
             $stringLength++;
         }
         if ($this->isBracketClose($char)) {
             $stack->pop();
             if ($stack->count() === 0 && $findSubFormula) {
                 $subFormulas[substr($formula, $stringStart, $stringLength)] = substr($formula, $stringStart, $stringLength);
                 $findSubFormula = false;
                 $stringLength = 0;
             }
         }
     }
     if (count($subFormulas) > 0) {
         foreach ($subFormulas as &$subFormula) {
             $temp = trim(substr($subFormula, 1, strlen($subFormula) - 2));
             $subFormula = $this->solve($temp);
         }
         $formula = str_replace(array_keys($subFormulas), array_values($subFormulas), $formula);
     }
     $elems = new \SplDoublyLinkedList();
     array_map(function ($item) use($elems) {
         if ($item != ' ') {
             $elems->push($item);
         }
     }, explode(' ', $formula));
     while ($elems->count() > 1) {
         $maxPriority = 0;
         $index = 0;
         foreach ($elems as $i => $el) {
             if (isset(static::$symbols[$el]) && static::$symbols[$el] > $maxPriority) {
                 $maxPriority = static::$symbols[$el];
                 $index = $i;
             }
         }
         $this->process($index, $elems);
     }
     return $elems->pop();
 }
開發者ID:ygto,項目名稱:calculator,代碼行數:54,代碼來源:Calculator.php

示例8: info

 /**
  * Returns the array of logs.
  *
  * @return array
  */
 public function info()
 {
     if ($this->working) {
         throw new LogicException("It is not possible get info on a working Pipeline.");
     }
     $info = ['context' => $this->context];
     while ($this->DTOs->count()) {
         $info[] = $this->DTOs->pop()->toArray($this);
     }
     return $info;
 }
開發者ID:toobo,項目名稱:pipepie,代碼行數:16,代碼來源:Pipeline.php

示例9: close

 /**
  * Close current block.
  *
  * @param  string|null $which
  * @return string
  */
 public function close($which = null)
 {
     if (!$this->buffers->count()) {
         throw new LogicException('It is not possible to close a never opened block.');
     }
     list($buffer, $name) = $this->buffers->pop();
     if (!is_null($which) && $which !== $name) {
         throw new InvalidArgumentException("Please close blocks in order: you need to close other block(s) before \"{$which}\".");
     }
     $output = $buffer instanceof Block ? $buffer->close() : '';
     return $output;
 }
開發者ID:corner82,項目名稱:Slim_SanalFabrika,代碼行數:18,代碼來源:Blocks.php

示例10: bubbleStack

 /**
  * Bubbles the stack.
  *
  * Whenever another level in the render array has been rendered, the stack
  * must be bubbled, to merge its rendering metadata with that of the parent
  * element.
  */
 protected function bubbleStack()
 {
     // If there's only one frame on the stack, then this is the root call, and
     // we can't bubble up further. Reset the stack for the next root call.
     if (static::$stack->count() === 1) {
         $this->resetStack();
         return;
     }
     // Merge the current and the parent stack frame.
     $current = static::$stack->pop();
     $parent = static::$stack->pop();
     static::$stack->push($current->merge($parent));
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:20,代碼來源:Renderer.php

示例11: getStackAsString

 /**
  * @param \SplStack $metadataStack
  * @return null|string
  */
 protected function getStackAsString(\SplStack $metadataStack)
 {
     if ($metadataStack->count() > 1) {
         $propertyNames = [];
         foreach ($metadataStack as $metadata) {
             if ($metadata instanceof PropertyMetadata) {
                 $propertyNames[] = $metadata->name;
             }
         }
         $propertyNames = array_reverse($propertyNames);
         return implode('.', $propertyNames);
     }
     return null;
 }
開發者ID:glavweb,項目名稱:GlavwebRestBundle,代碼行數:18,代碼來源:ScopeExclusionStrategy.php

示例12: isPalindrome

function isPalindrome($word)
{
    $word = strtolower(str_replace(" ", "", $word));
    $stack = new SplStack();
    $cnt = strlen($word);
    for ($i = 0; $i < $cnt; ++$i) {
        $stack->push($word[$i]);
    }
    $rword = "";
    while ($stack->count() > 0) {
        $rword .= $stack->pop();
    }
    return $word == $rword;
}
開發者ID:kapsilon,項目名稱:Specialist,代碼行數:14,代碼來源:15-Stack.php

示例13: endVisiting

 public function endVisiting($data, Type $type, Context $context)
 {
     $nodes = $this->currentNodes ?: [];
     $this->currentNodes = $this->nodeStack->pop();
     if ($this->nodeStack->count() === 0 && $this->document->documentElement === null) {
         $rootNode = $this->document->createElement('result');
         $this->document->appendChild($rootNode);
         $this->currentNodes = $rootNode;
     }
     if (!is_array($nodes) && !$nodes instanceof \DOMNodeList) {
         $this->currentNodes->appendChild($nodes);
         return;
     }
     foreach ($nodes as $node) {
         $this->currentNodes->appendChild($node);
     }
 }
開發者ID:alekitto,項目名稱:serializer,代碼行數:17,代碼來源:XmlSerializationVisitor.php

示例14: render

 /**
  * Render a common_report_Report object into an HTML string output.
  * 
  * @param common_report_Report $report A report to be rendered
  * @return string The HTML rendering.
  */
 public static function render(common_report_Report $report)
 {
     $stack = new SplStack();
     $renderingStack = new SplStack();
     $traversed = array();
     $stack->push($report);
     $nesting = 0;
     while ($stack->count() > 0) {
         $current = $stack->pop();
         if (in_array($current, $traversed, true) === false && $current->hasChildren() === true) {
             $nesting++;
             // -- Hierarchical report, 1st pass (descending).
             // Repush report for a 2ndpass.
             $stack->push($current);
             // Tag as already traversed.
             $traversed[] = $current;
             // Push the children for a 1st pass.
             foreach ($current as $child) {
                 $stack->push($child);
             }
         } else {
             if (in_array($current, $traversed, true) === true && $current->hasChildren() === true) {
                 $nesting--;
                 // -- Hierachical report, 2nd pass (ascending).
                 // Get the nested renderings of the current report.
                 $children = array();
                 foreach ($current as $child) {
                     $children[] = $renderingStack->pop();
                 }
                 $renderingStack->push(self::renderReport($current, $children, $nesting));
             } else {
                 // -- Leaf report, 1st & single pass.
                 $renderingStack->push(self::renderReport($current, array(), $nesting, true));
             }
         }
     }
     return $renderingStack->pop();
 }
開發者ID:nagyist,項目名稱:tao-core,代碼行數:44,代碼來源:class.Rendering.php

示例15: countParentIds

 /**
  * @return int
  */
 public function countParentIds()
 {
     return $this->traversalStack->count();
 }
開發者ID:helstern,項目名稱:nomsky-lib,代碼行數:7,代碼來源:VisitContext.php


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