双链表是一种重要的线性存储结构,对于双链表中的每个节点,不仅仅存储自己的信息,还要保存前驱和后继节点的地址。
PHP SPL中的SplDoublyLinkedList类提供了对双链表的操作。
SplDoublyLinkedList类摘要如下:
SplDoublyLinkedList implements Iterator , ArrayAccess , Countable { public __construct ( void ) public void add ( mixed $index , mixed $newval ) //双链表的头部节点 public mixed top ( void ) //双链表的尾部节点 public mixed bottom ( void ) //双联表元素的个数 public int count ( void ) //检测双链表是否为空 public bool isEmpty ( void ) //当前节点索引 public mixed key ( void ) //移到上条记录 public void prev ( void ) //移到下条记录 public void next ( void ) //当前记录 public mixed current ( void ) //将指针指向迭代开始处 public void rewind ( void ) //检查双链表是否还有节点 public bool valid ( void ) //指定index处节点是否存在 public bool offsetExists ( mixed $index ) //获取指定index处节点值 public mixed offsetGet ( mixed $index ) //设置指定index处值 public void offsetSet ( mixed $index , mixed $newval ) //删除指定index处节点 public void offsetUnset ( mixed $index ) //从双链表的尾部弹出元素 public mixed pop ( void ) //添加元素到双链表的尾部 public void push ( mixed $value ) //序列化存储 public string serialize ( void ) //反序列化 public void unserialize ( string $serialized ) //设置迭代模式 public void setIteratorMode ( int $mode ) //获取迭代模式SplDoublyLinkedList::IT_MODE_LIFO (Stack style) SplDoublyLinkedList::IT_MODE_FIFO (Queue style) public int getIteratorMode ( void ) //双链表的头部移除元素 public mixed shift ( void ) //双链表的头部添加元素 public void unshift ( mixed $value ) }
使用起来也是简单
$list = new SplDoublyLinkedList(); $list->push('a'); $list->push('b'); $list->push('c'); $list->unshift('top'); $list->shift(); print_r(array( 'pop' => $list->pop(), 'count' => $list->count(), 'isEmpty' => $list->isEmpty(), 'bottom' => $list->bottom(), 'top' => $list->top() )); $list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); print_r($list->getIteratorMode()); for($list->rewind(); $list->valid(); $list->next()) { echo $list->current().PHP_EOL; } print_r($a = $list->serialize()); //print_r($list->unserialize($a)); $list->offsetSet(0,'new one'); $list->offsetUnset(0); print_r(array( 'offsetExists' => $list->offsetExists(4), 'offsetGet' => $list->offsetGet(0), )); print_r($list);
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2024年10月03日
2024年10月03日
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】
- 李恕权.2003-回·20年全精选2CD【SONY】【WAV+CUE】