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


PHP SplDoublyLinkedList::pop方法代码示例

本文整理汇总了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";
}
开发者ID:balajivenki,项目名称:php-judy,代码行数:31,代码来源:judy-bench-bitset.php

示例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();
开发者ID:ray0916,项目名称:learn,代码行数:31,代码来源:splDoublyLinkedList.php

示例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);
 }
开发者ID:thumbtack,项目名称:crankshaft,代码行数:27,代码来源:Iterable.php

示例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);
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_spl_tests_dllist_001.php

示例5: SplDoublyLinkedList

<?php

$array = new SplDoublyLinkedList();
$get = $array->pop('param');
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:SplDoublyLinkedList_pop_params.php

示例6: SplDoublyLinkedList

<?php

$ll = new SplDoublyLinkedList();
$ll->push(1);
$ll->push(2);
var_dump($ll->pop(1));
开发者ID:badlamer,项目名称:hhvm,代码行数:6,代码来源:SplDoublyLinkedList_pop_noParams.php

示例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;
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:SplDoublyLinkedList_pop.php

示例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));
开发者ID:php-ds,项目名称:benchmarks,代码行数:31,代码来源:config.php

示例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();
 }
开发者ID:mohiva,项目名称:common,代码行数:10,代码来源:TokenStream.php


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