class SplDoublyLinkedList implements Iterator, Traversable, Countable, ArrayAccess {
const IT_MODE_LIFO = 2;
const IT_MODE_FIFO = 0;
const IT_MODE_DELETE = 1;
const IT_MODE_KEEP = 0; /**
* Add/insert a new value at the specified index
* @param mixed $index The index where the new value is to be inserted.
* @param mixed $newval The new value for the index.
* @link http://php.net/spldoublylinkedlist.add
* @return void
* @since 5.5.0
*/
public function add($index, $newval) {} /**
* Pops a node from the end of the doubly linked list
* @link http://php.net/manual/en/spldoublylinkedlist.pop.php
* @return mixed The value of the popped node.
* @since 5.3.0
*/
public function pop () {} /**
* Shifts a node from the beginning of the doubly linked list
* @link http://php.net/manual/en/spldoublylinkedlist.shift.php
* @return mixed The value of the shifted node.
* @since 5.3.0
*/
public function shift () {} /**
* Pushes an element at the end of the doubly linked list
* @link http://php.net/manual/en/spldoublylinkedlist.push.php
* @param mixed $value <p>
* The value to push.
* </p>
* @return void
* @since 5.3.0
*/
public function push ($value) {} /**
* Prepends the doubly linked list with an element
* @link http://php.net/manual/en/spldoublylinkedlist.unshift.php
* @param mixed $value <p>
* The value to unshift.
* </p>
* @return void
* @since 5.3.0
*/
public function unshift ($value) {} /**
* Peeks at the node from the end of the doubly linked list
* @link http://php.net/manual/en/spldoublylinkedlist.top.php
* @return mixed The value of the last node.
* @since 5.3.0
*/
public function top () {} /**
* Peeks at the node from the beginning of the doubly linked list
* @link http://php.net/manual/en/spldoublylinkedlist.bottom.php
* @return mixed The value of the first node.
* @since 5.3.0
*/
public function bottom () {} /**
* Counts the number of elements in the doubly linked list.
* @link http://php.net/manual/en/spldoublylinkedlist.count.php
* @return int the number of elements in the doubly linked list.
* @since 5.3.0
*/
public function count () {} /**
* Checks whether the doubly linked list is empty.
* @link http://php.net/manual/en/spldoublylinkedlist.isempty.php
* @return bool whether the doubly linked list is empty.
* @since 5.3.0
*/
public function isEmpty () {} /**
* Sets the mode of iteration
* @link http://php.net/manual/en/spldoublylinkedlist.setiteratormode.php
* @param int $mode <p>
* There are two orthogonal sets of modes that can be set:
* </p>
* The direction of the iteration (either one or the other):
* <b>SplDoublyLinkedList::IT_MODE_LIFO</b> (Stack style)
* @return void
* @since 5.3.0
*/
public function setIteratorMode ($mode) {} /**
* Returns the mode of iteration
* @link http://php.net/manual/en/spldoublylinkedlist.getiteratormode.php
* @return int the different modes and flags that affect the iteration.
* @since 5.3.0
*/
public function getIteratorMode () {} /**
* Returns whether the requested $index exists
* @link http://php.net/manual/en/spldoublylinkedlist.offsetexists.php
* @param mixed $index <p>
* The index being checked.
* </p>
* @return bool true if the requested <i>index</i> exists, otherwise false
* @since 5.3.0
*/
public function offsetExists ($index) {} /**
* Returns the value at the specified $index
* @link http://php.net/manual/en/spldoublylinkedlist.offsetget.php
* @param mixed $index <p>
* The index with the value.
* </p>
* @return mixed The value at the specified <i>index</i>.
* @since 5.3.0
*/
public function offsetGet ($index) {} /**
* Sets the value at the specified $index to $newval
* @link http://php.net/manual/en/spldoublylinkedlist.offsetset.php
* @param mixed $index <p>
* The index being set.
* </p>
* @param mixed $newval <p>
* The new value for the <i>index</i>.
* </p>
* @return void
* @since 5.3.0
*/
public function offsetSet ($index, $newval) {} /**
* Unsets the value at the specified $index
* @link http://php.net/manual/en/spldoublylinkedlist.offsetunset.php
* @param mixed $index <p>
* The index being unset.
* </p>
* @return void
* @since 5.3.0
*/
public function offsetUnset ($index) {} /**
* Rewind iterator back to the start
* @link http://php.net/manual/en/spldoublylinkedlist.rewind.php
* @return void
* @since 5.3.0
*/
public function rewind () {} /**
* Return current array entry
* @link http://php.net/manual/en/spldoublylinkedlist.current.php
* @return mixed The current node value.
* @since 5.3.0
*/
public function current () {} /**
* Return current node index
* @link http://php.net/manual/en/spldoublylinkedlist.key.php
* @return mixed The current node index.
* @since 5.3.0
*/
public function key () {} /**
* Move to next entry
* @link http://php.net/manual/en/spldoublylinkedlist.next.php
* @return void
* @since 5.3.0
*/
public function next () {} /**
* Move to previous entry
* @link http://php.net/manual/en/spldoublylinkedlist.prev.php
* @return void
* @since 5.3.0
*/
public function prev () {} /**
* Check whether the doubly linked list contains more nodes 当前指针处元素是否有效
* @link http://php.net/manual/en/spldoublylinkedlist.valid.php
* @return bool true if the doubly linked list contains any more nodes, false otherwise.
* @since 5.3.0
*/
public function valid () {} /**
* Unserializes the storage
* @link http://php.net/manual/ru/spldoublylinkedlist.serialize.php
* @param string $serialized The serialized string.
* @return void
* @since 5.4.0
*/
public function unserialize($serialized) {} /**
* Serializes the storage
* @link http://php.net/manual/ru/spldoublylinkedlist.unserialize.php
* @return string The serialized string.
* @since 5.4.0
*/
public function serialize () {} }

用例

<?php
header("Content-type: text/html; charset=gb2312");
$doubly=new SplDoublyLinkedList();
$doubly->push('a');
$doubly->push('b');
$doubly->push('c');
$doubly->push('d');
$doubly->add(1,'e'); echo 'Original:'."\n";
var_dump($doubly); echo 'FIFO|KEEP:'."\n";
$doubly->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
$doubly->rewind();
foreach($doubly as $key=>$value)
{
echo $key.' '.$value."\n";
} echo 'LIFO|KEEP:'."\n";
$doubly->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
$doubly->rewind();
foreach($doubly as $key=>$value)
{
echo $key.' '.$value."\n";
} echo 'LIFO|DELETE:'."\n";
$doubly->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_DELETE);
$doubly->rewind();
foreach($doubly as $key=>$value)
{
if($key == 1) break;
echo $key.' '.$value."\n";
}
echo 'List after Delete'."\n";
var_dump($doubly);
?>

PHP标准库(SPL)- SplDoublyLinkedList类(双向链表)的更多相关文章

  1. PHP 标准库 SPL 之数据结构栈(SplStack)简单实践

    PHP 5.3.0 版本及以上的堆栈描述可以使用标准库 SPL 中的 SplStack class,SplStack 类继承双链表 ( SplDoublyLinkedList ) 实现栈. 代码: & ...

  2. php标准库spl栈SplStack如何使用?

    php标准库spl栈SplStack如何使用? 一.总结 php标准库spl栈SplStack介绍.(SplStack类)(各种方法都支持) 1.SplStack类:$stack = new SplS ...

  3. C++解析(18):C++标准库与字符串类

    0.目录 1.C++标准库 2.字符串类 3.数组操作符的重载 4.小结 1.C++标准库 有趣的重载--操作符 << 的原生意义是按位左移,例:1 << 2;,其意义是将整数 ...

  4. C 和 C++ 的标准库分别有自己的 locale 操作方法,C 标准库的 locale 设定函数是 setlocale(),而 C++ 标准库有 locale 类和流对象的 imbue() 方法(gcc使用zh_CN.GBK,或者zh_CN.UTF-8,VC++使用Chinese_People's Republic of China.936或者65001.)

    转自:http://zyxhome.org/wp/cc-prog-lang/c-stdlib-setlocale-usage-note/ [在此向原文作者说声谢谢!若有读者看到文章转载时请写该转载地址 ...

  5. PHP标准库 (SPL) 笔记

    简介 SPL是Standard PHP Library(PHP标准库)的缩写. The Standard PHP Library (SPL) is a collection of interfaces ...

  6. 【夯实PHP基础】PHP标准库 SPL

    PHP SPL笔记 这几天,我在学习PHP语言中的SPL. 这个东西应该属于PHP中的高级内容,看上去很复杂,但是非常有用,所以我做了长篇笔记.不然记不住,以后要用的时候,还是要从头学起. 由于这是供 ...

  7. PHP标准库 SPL

    PHP SPL笔记 这几天,我在学习PHP语言中的SPL. 这个东西应该属于PHP中的高级内容,看上去很复杂,但是非常有用,所以我做了长篇笔记.不然记不住,以后要用的时候,还是要从头学起. 由于这是供 ...

  8. PHP标准库SPL

    SPL是Standard PHP Library(PHP标准库)的缩写.用来解决典型(常见)问题(common problems)的一组接口与类的集合 典型问题(common problems) - ...

  9. 基于标准库的string类实现简单的字符串替换

    感觉基本功还是不扎实,虽然能做些程序但是现在看来我还是个初学者(primer),试着完成习题结果还得修修改改. 废话不多说,实现功能很简单,<C++ Primer>9.5.2节习题. // ...

  10. Python - 标准库部分函数、类的大致实现(持续更新)

    all() def all(iterable): for element in iterbale: if not element: return False return True any() def ...

随机推荐

  1. Shell条件与测试

    分类参考 文件状态测试 -b filename 当filename 存在并且是块文件时返回真(返回0) -c filename 当filename 存在并且是字符文件时返回真 -d pathname ...

  2. POJ3268Dijkstra

    题意:给定n个点,m条边,求所有顶点中到顶点x的来回最短距离 分析:考虑到数据范围,选用Dijkstra,用Floyd会超时 #include <iostream> #include &l ...

  3. 2、手把手教你Extjs5(二)项目中文件的加载过程

    上一节中用sencha工具自动创建了一个项目,并且可以在浏览器中查看.现在我们来看看js类加载过程.如下图所示: 1、首先:浏览器中输入 localhost:1841 ,调用 index.html; ...

  4. 单片机联网,UIP实现tcp/udp协议

    UIP是单片机界联网的一个很好地选择,移植这个库有点复杂,首先是第一步,网卡驱动要写好,使用的网卡芯片为ENC28J60,驱动可以再工程包里面找到 //配置网卡硬件,并设置MAC地址 //返回值:0, ...

  5. Unity3D ——强大的跨平台3D游戏开发工具(二)

    第二章 Unity3D的简单预览 每个Unity3D版本都会自带一个Demo源文件.在3.0的正式版中,自带的Demo就是网上展示的那款强大的射击游戏.在一般情况下,您只要第一次 打开Unity3D ...

  6. HTML CSS基础(二)

    块元素和行内元素 HTML元素根据表现形式,可以分为2类: (1)块元素(block): (2)行内元素(inline): 任何HTML元素都属于这两类中的其中一类. 2.块元素特点: (1)独占一行 ...

  7. 设置git账号并生成新的ssh(切换电脑用户之后)

    1.设置账号 2.设置邮箱 3.检查确认 4. 5.check-----成功~

  8. MySQL数据库面试

    1. MySql的存储引擎的不同 特点 Myisam BDB Memory InnoDB Archive 存储限制 没有 没有 有 64TB 没有 事务安全   支持   支持   锁机制 表锁 页锁 ...

  9. Grunt构建工具插件篇——之less工具

    Grunt--Less 摘要: 之前介绍了自动构建工具Grunt,其中有一个模块是"grunt-contrib-less",下面是配置Grunt自动编译less文件. 安装: Gr ...

  10. jQuery原型技术分解

    jQuery原型技术分解 起源----原型继承 用户过javascript的都会明白,在javascript脚本中到处都是 函数,函数可以归置代码段,把相对独立的功能封闭在一个函数包中.函数也可以实现 ...