# SplDoublyLinkedList 类

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

## 简介

SplDoublyLinkedList 类提供双向链表的主要功能。

## 类摘要

class SplDoublyLinkedList implements Iterator, Countable, ArrayAccess, Serializable {
/* 常量 */
public const int IT_MODE_LIFO;
public const int IT_MODE_FIFO;
public const int IT_MODE_DELETE;
public const int IT_MODE_KEEP;
/* 方法 */
public function add(int `$index`, mixed `$value`): void
public function bottom(): mixed
public function count(): int
public function current(): mixed
public function getIteratorMode(): int
public function isEmpty(): bool
public function key(): int
public function next(): void
public function offsetExists(int `$index`): bool
public function offsetGet(int `$index`): mixed
public function offsetSet(?int `$index`, mixed `$value`): void
public function offsetUnset(int `$index`): void
public function pop(): mixed
public function prev(): void
public function push(mixed `$value`): void
public function rewind(): void
public function serialize(): string
public function setIteratorMode(int `$mode`): int
public function shift(): mixed
public function top(): mixed
public function unserialize(string `$data`): void
public function unshift(mixed `$value`): void
public function valid(): bool
}

## 预定义常量

## 迭代方向

`SplDoublyLinkedList::IT_MODE_LIFO`

  列表将以先进后出的顺序迭代，就像栈一样。

`SplDoublyLinkedList::IT_MODE_FIFO`

  列表将以先进先出的顺序迭代，就像队列一样。

## 迭代行为

`SplDoublyLinkedList::IT_MODE_DELETE`

  迭代将移除已迭代的元素。

`SplDoublyLinkedList::IT_MODE_KEEP`

  迭代将不会移除已迭代的元素。

## 目录

- SplDoublyLinkedList::add — Add/insert a new value at the specified index
- SplDoublyLinkedList::bottom — Peeks at the node from the beginning of the doubly linked list
- SplDoublyLinkedList::count — Counts the number of elements in the doubly linked list
- SplDoublyLinkedList::current — Return current array entry
- SplDoublyLinkedList::getIteratorMode — Returns the mode of iteration
- SplDoublyLinkedList::isEmpty — Checks whether the doubly linked list is empty
- SplDoublyLinkedList::key — Return current node index
- SplDoublyLinkedList::next — Move to next entry
- SplDoublyLinkedList::offsetExists — Returns whether the requested $index exists
- SplDoublyLinkedList::offsetGet — Returns the value at the specified $index
- SplDoublyLinkedList::offsetSet — Sets the value at the specified $index to $value
- SplDoublyLinkedList::offsetUnset — Unsets the value at the specified $index
- SplDoublyLinkedList::pop — Pops a node from the end of the doubly linked list
- SplDoublyLinkedList::prev — Move to previous entry
- SplDoublyLinkedList::push — Pushes an element at the end of the doubly linked list
- SplDoublyLinkedList::rewind — Rewind iterator back to the start
- SplDoublyLinkedList::serialize — Serializes the storage
- SplDoublyLinkedList::setIteratorMode — Sets the mode of iteration
- SplDoublyLinkedList::shift — Shifts a node from the beginning of the doubly linked list
- SplDoublyLinkedList::top — Peeks at the node from the end of the doubly linked list
- SplDoublyLinkedList::unserialize — Unserializes the storage
- SplDoublyLinkedList::unshift — Prepends the doubly linked list with an element
- SplDoublyLinkedList::valid — Check whether the doubly linked list contains more nodes

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open