The Sequence interface
A Sequence describes the behaviour of values arranged in a single, linear dimension. Some languages refer to this as a "List". It’s similar to an array that uses incremental integer keys, with the exception of a few characteristics: Values will always be indexed as [0, 1, 2, …, size - 1].Only allowed to access values by index in the range [0, size - 1].
Intro
A Sequence describes the behaviour of values arranged in a single, linear dimension. Some languages refer to this as a "List". It’s similar to an array that uses incremental integer keys, with the exception of a few characteristics:
- Values will always be indexed as [0, 1, 2, …, size - 1].
- Only allowed to access values by index in the range [0, size - 1].
Use cases:
- Wherever you would use an array as a list (not concerned with keys).
- A more efficient alternative to
SplDoublyLinkedListandSplFixedArray.
Interfacesynopsis
Changelog
| Version | Description |
|---|---|
| PECL ds 1.3.0 | The interface now extends ArrayAccess. |
Sequence