本文整理汇总了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());
}
示例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;
}
}
示例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++;
}
示例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();
}
}
示例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");
}
示例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";
}
示例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);