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