本文整理汇总了PHP中SplDoublyLinkedList::pop方法的典型用法代码示例。如果您正苦于以下问题:PHP SplDoublyLinkedList::pop方法的具体用法?PHP SplDoublyLinkedList::pop怎么用?PHP SplDoublyLinkedList::pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplDoublyLinkedList
的用法示例。
在下文中一共展示了SplDoublyLinkedList::pop方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unset
echo "Mem real: " . __convert(memory_get_usage(true)) . "\n";
unset($array);
echo "\n-- SplDoublyLinkedList \n";
echo "Mem usage: " . __convert(memory_get_usage()) . "\n";
echo "Mem real: " . __convert(memory_get_usage(true)) . "\n";
$s = microtime(true);
$spl = new SplDoublyLinkedList();
for ($i = 0; $i < $v; $i++) {
$spl->push($i);
}
try {
$spl->offsetUnset(102);
var_dump($spl->offsetGet(100));
var_dump($spl->offsetGet(102));
} catch (OutOfRangeException $e) {
echo $e;
}
$e = microtime(true);
echo "Count: " . $spl->count() . "\n";
echo "Elapsed time: " . ($e - $s) . " sec.\n";
echo "Mem usage: " . __convert(memory_get_usage()) . "\n";
echo "Mem real: " . __convert(memory_get_usage(true)) . "\n";
try {
for ($i = 0; $i < $v; $i++) {
$spl->pop();
}
} catch (Exception $e) {
}
unset($spl);
echo "\n";
}
示例2: SplDoublyLinkedList
* 栈SplStack
* 队列SplQueue
*
* 栈和队列都是继承于双向链表,所以,所有双向链表的方法都可以被栈和队列使用。调用方法也一致。
*/
$list = new SplDoublyLinkedList();
// push($value)
// 在结尾插入一个新值
$list->push('value1');
$list->push('value2');
$list->push('value3');
$list->push('value4');
$list->push('value5');
// pop()
// 抛出结尾的一个元素,会使得链表结构减少一个
$list->pop();
// key()
// 获得当前节点的索引值
$list->key();
// count()
// 获得链表的数量
$list->count();
// rewind()
// 将指针返回至初始节点
$list->rewind();
// current()
// 获得当前节点
$list->current();
// top()
// 返回最后一个节点的值
$list->top();
示例3: reverse
/**
* Make an iterable that will yield this iterable's values in reverse order. Keys in the
* original iterable will be preserved.
*
* This iterable will be consumed in its entirety when `reverse()` is called.
*
* Examples
*
* Crankshaft::Iter(['a', 'b', 'c', 'd', 'e'])->reverse()->to_array()
* // => [4 => 'e', 3 => 'd, 2 => 'c', 1 => 'b', 0 => 'a']
*
* Returns an Iterable.
*/
public function reverse()
{
$keys = new \SplDoublyLinkedList();
$values = new \SplDoublyLinkedList();
foreach ($this as $key => $value) {
$keys->push($key);
$values->push($value);
}
$reversed = [];
while (!$values->isEmpty()) {
$reversed[$keys->pop()] = $values->pop();
}
return Crankshaft::Iter($reversed);
}
示例4: SplDoublyLinkedList
<?php
$dll = new SplDoublyLinkedList();
// errors
try {
$dll->pop();
} catch (RuntimeException $e) {
echo "Exception: " . $e->getMessage() . "\n";
}
try {
$dll->shift();
} catch (RuntimeException $e) {
echo "Exception: " . $e->getMessage() . "\n";
}
// data consistency
$a = 2;
$dll->push($a);
echo $dll->pop() . "\n";
$a = 2;
$dll->unshift($a);
echo $dll->shift() . "\n";
// peakable
$dll->push(1);
$dll->push(2);
echo $dll->top() . "\n";
echo $dll->bottom() . "\n";
$dll->pop();
$dll->pop();
// countable
$dll->push(NULL);
$dll->push(NULL);
示例5: SplDoublyLinkedList
<?php
$array = new SplDoublyLinkedList();
$get = $array->pop('param');
示例6: SplDoublyLinkedList
<?php
$ll = new SplDoublyLinkedList();
$ll->push(1);
$ll->push(2);
var_dump($ll->pop(1));
示例7: SplDoublyLinkedList
<?php
$dll = new SplDoublyLinkedList();
$dll->push('foo');
$dll->push('bar');
echo $dll->pop(), PHP_EOL;
$dll->rewind();
echo $dll->current(), PHP_EOL;
$dll->next();
echo $dll->current(), PHP_EOL;
示例8: range
global $a;
$a = range(1, $n);
}, function ($i) {
global $a;
array_pop($a);
}, function () {
global $a;
$a = null;
}], SPL_DLL => [function ($n) {
global $a;
$a = new SplDoublyLinkedList();
for (; $n--; $a[] = rand()) {
}
}, function ($i) {
global $a;
$a->pop();
}, function () {
global $a;
$a = null;
}], VECTOR => [function ($n) {
global $a;
$a = new Vector(range(1, $n));
}, function ($i) {
global $a;
$a->pop();
}, function () {
global $a;
$a = null;
}], DEQUE => [function ($n) {
global $a;
$a = new Deque(range(1, $n));
示例9: pop
/**
* Pops a `Token` from the end of the list.
*
* @return Token The popped token.
* @link http://www.php.net/manual/en/spldoublylinkedlist.pop.php
*/
public function pop()
{
return $this->tokens->pop();
}