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

classSplDoublyLinkedListimplementsIterator, Countable, ArrayAccess, Serializable {
publicconstintIT_MODE_LIFO;
publicconstintIT_MODE_FIFO;
publicconstintIT_MODE_DELETE;
publicconstintIT_MODE_KEEP;
publicadd(int$index, mixed$value): void
publicbottom(): mixed
publiccount(): int
publiccurrent(): mixed
publicisEmpty(): bool
publickey(): int
publicnext(): void
publicoffsetExists(int$index): bool
publicoffsetGet(int$index): mixed
publicoffsetSet(?int$index, mixed$value): void
publicoffsetUnset(int$index): void
publicpop(): mixed
publicprev(): void
publicpush(mixed$value): void
publicrewind(): void
publicserialize(): string
publicsetIteratorMode(int$mode): int
publicshift(): mixed
publictop(): mixed
publicunserialize(string$data): void
publicunshift(mixed$value): void
publicvalid(): 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

To Top