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


PHP Stack::isEmpty方法代码示例

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


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

示例1: testIsEmpty

 public function testIsEmpty()
 {
     // Remove the following lines when you implement this test.
     $this->assertFalse($this->object->isEmpty());
     $this->object->clear();
     $this->assertFalse(!$this->object->isEmpty());
 }
开发者ID:robo47,项目名称:BlazeFramework,代码行数:7,代码来源:StackTest.php

示例2: rewind

 /**
  * @link http://php.net/manual/en/iterator.rewind.php
  * @return void
  */
 function rewind()
 {
     $this->stack = new LinkedStack();
     $this->pushLeft($this->root);
     if (!$this->stack->isEmpty()) {
         $this->node = $this->stack->last();
         $this->key = 0;
     }
 }
开发者ID:RadekDvorak,项目名称:Ardent,代码行数:13,代码来源:InOrderIterator.php

示例3: next

 /**
  * @link http://php.net/manual/en/iterator.next.php
  * @return void
  */
 function next()
 {
     /**
      * @var BinaryTree $node
      */
     $node = $this->stack->pop();
     $this->pushIfNotNull('right', $node);
     $this->pushIfNotNull('left', $node);
     if ($this->stack->isEmpty()) {
         $this->value = $this->key = null;
         return;
     }
     $this->value = $this->stack->last();
     $this->key++;
 }
开发者ID:pramoddas,项目名称:Ardent,代码行数:19,代码来源:PreOrderIterator.php

示例4: next_right

 private function next_right()
 {
     $right = $this->value->right();
     if ($right !== null && !$this->stack->isEmpty() && $right === $this->stack->last()) {
         $this->stack->pop();
         $this->next_push($right);
     } else {
         $this->next_set();
     }
 }
开发者ID:pramoddas,项目名称:Ardent,代码行数:10,代码来源:PostOrderIterator.php

示例5: callInclude

 /**
  * Vložení souboru
  *
  * @param string
  * @param string
  * @return void
  */
 protected function callInclude(array $include)
 {
     $value = $this->reduceValue($include[2]);
     if ($value[0] !== 'string') {
         throw new CompileException("Název vkládaného souboru musí být řetězec");
     }
     $file = Compiler::stringDecode($value[1]);
     $path = ($this->files->isEmpty() ? '' : dirname($this->files->top()) . DIRECTORY_SEPARATOR) . $file;
     $extension = pathinfo($file, PATHINFO_EXTENSION);
     if (!is_file($path) || !is_readable($path)) {
         throw new CompileException("Soubor '{$path}' neexistuje nebo jej nelze přečíst");
     } elseif ($extension == 'iss') {
         $this->addFile($path);
         try {
             $tree = $this->parser->parse(file_get_contents($this->getFile()));
             if ($include[3] !== NULL) {
                 $block = new Media($include[3], $include[4]);
                 $block->properties = $tree->properties;
                 $this->reduceBlock($block);
             } else {
                 $this->reduceBlock($tree);
             }
         } catch (CompileException $e) {
             throw $e->setFile($this->getFile());
         }
         $this->removeFile($path);
         return;
     } elseif ($extension == 'css') {
         $this->addFile($path);
         $context =& $this->getReducedContext();
         $context[] = file_get_contents($path);
         $this->removeFile($path);
         return;
     }
     throw new CompileException("Soubor '{$path}' nemá koncovku .css ani .iss");
 }
开发者ID:enumag,项目名称:ivory,代码行数:43,代码来源:Analyzer.php

示例6: push

class Stack
{
    private $data = array();
    public function push($element)
    {
        $this->data[] = $element;
    }
    public function pop()
    {
        if ($this->isEmpty()) {
            return null;
        }
        return array_pop($this->data);
    }
    public function isEmpty()
    {
        return count($this->data) == 0;
    }
}
foreach (file($argv[1]) as $line) {
    $stack = new Stack();
    foreach (explode(" ", trim($line)) as $number) {
        $stack->push($number);
    }
    $toPrint = array();
    while (!$stack->isEmpty()) {
        $toPrint[] = $stack->pop();
        $stack->pop();
    }
    echo implode(" ", $toPrint) . "\n";
}
开发者ID:eandbsoftware,项目名称:CodeEval-1,代码行数:31,代码来源:StackImplementation.php

示例7: isEmpty

        } else {
            echo "stack is empty";
        }
    }
    public function isEmpty()
    {
        if ($this->index == -1) {
            return true;
        } else {
            return false;
        }
    }
    public function first()
    {
        echo $this->stackArray[$this->index];
    }
    public function last()
    {
        echo $this->stackArray[0];
    }
}
$newStack = new Stack();
$newStack->push(2);
$newStack->push(6);
$newStack->pop();
$newStack->pop();
$newStack->pop();
$newStack->isEmpty();
$newStack->first();
$newStack->last();
$newStack->getElement(1);
开发者ID:sanjidarafin,项目名称:FTFLOOPHP,代码行数:31,代码来源:pochaStack.php


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