The SplDoublyLinkedList class

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

Introduction

The SplDoublyLinkedList class provides the main functionalities of a doubly linked list.

Class synopsis

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

Predefined Constants

Iteration Direction

SplDoublyLinkedList::IT_MODE_LIFO

The list will be iterated in a last in, first out order, like a stack.

SplDoublyLinkedList::IT_MODE_FIFO

The list will be iterated in a first in, first out order, like a queue.

Iteration Behavior

SplDoublyLinkedList::IT_MODE_DELETE

Iteration will remove the iterated elements.

SplDoublyLinkedList::IT_MODE_KEEP

Iteration will not remove the iterated elements.

Table of Contents