StrictQueue
extends SplQueue
in package
uses
StrictSplDoublyLinkedListTrait
A type-sensitive, taversable queue (FIFO).
Extends \SplQueue with an option to restrict the allowed data types for list items by providing the constructor with an array of atomic types or fully qualified class names.
Tags
Table of Contents
Methods
- __construct() : void
- Create a type-sensitive, traversable list of items.
- add() : void
- Add/insert a new item at the specified offset.
- append() : void
- Append items at the end of the list.
- clear() : void
- Clear the list of any items.
- dequeue() : AllowedType
- Dequeue an item from the queue.
- enqueue() : void
- Add an item to the queue.
- get() : AllowedType
- Get the item at the specified index.
- isList() : true
- Check if this can be considered a list.
- offsetSet() : void
- Set the item at the specified offset.
- prepend() : void
- Prepend items at the start of the list.
- push() : void
- Push an item at the end of the list.
- remove() : void
- Remove an item from the list.
- set() : void
- Set an item at the specified index.
- toArray() : array<int, AllowedType>
- Return array representation of list.
- toStrictCollection() : StrictCollection<string|int, AllowedType>
- Turn list into a type-sensitive collection.
- unshift() : void
- Prepend the list with an item.
Methods
__construct()
Create a type-sensitive, traversable list of items.
public
__construct([array<string|int, string> $allowedTypes = [] ]) : void
Parameters
- $allowedTypes : array<string|int, string> = []
-
Allowed data types of items (optional)
If empty, all types are allowed. Possible values are:
- "array"
- "bool"
- "callable"
- "countable"
- "float" or "double"
- "int" or "integer" or "long"
- "iterable"
- "null"
- "numeric"
- "object" or FQCN
- "resource"
- "scalar"
- "string"
Tags
add()
Add/insert a new item at the specified offset.
public
add(int $offset, AllowedType $value) : void
Parameters
- $offset : int
-
The offset where the new item is to be inserted
- $value : AllowedType
-
The new item for the offset
Tags
append()
Append items at the end of the list.
public
append(AllowedType ...$values) : void
Parameters
- $values : AllowedType
-
One or more items to append
Tags
clear()
Clear the list of any items.
public
clear() : void
dequeue()
Dequeue an item from the queue.
public
dequeue() : AllowedType
Tags
Return values
AllowedType —The dequeued item
enqueue()
Add an item to the queue.
public
enqueue(AllowedType $value) : void
Parameters
- $value : AllowedType
-
The item to enqueue
Tags
get()
Get the item at the specified index.
public
get(int $offset) : AllowedType
Parameters
- $offset : int
-
The item's index
Tags
Return values
AllowedType —The item
isList()
Check if this can be considered a list.
public
isList() : true
Return values
true —Always TRUE (this exists only for compatibility reasons)
offsetSet()
Set the item at the specified offset.
public
offsetSet(int|null $offset, AllowedType $value) : void
Parameters
- $offset : int|null
-
The offset being set or NULL to append
- $value : AllowedType
-
The new item for the offset
Tags
prepend()
Prepend items at the start of the list.
public
prepend(AllowedType ...$values) : void
Parameters
- $values : AllowedType
-
One or more items to prepend
Tags
push()
Push an item at the end of the list.
public
push(AllowedType $value) : void
Parameters
- $value : AllowedType
-
The item to push
Tags
remove()
Remove an item from the list.
public
remove(int $offset) : void
Parameters
- $offset : int
-
The item's index
Tags
set()
Set an item at the specified index.
public
set(int $offset, AllowedType $value) : void
Parameters
- $offset : int
-
The item's index
- $value : AllowedType
-
The item
Tags
toArray()
Return array representation of list.
public
toArray() : array<int, AllowedType>
Return values
array<int, AllowedType> —Array of list items
toStrictCollection()
Turn list into a type-sensitive collection.
public
toStrictCollection() : StrictCollection<string|int, AllowedType>
Return values
StrictCollection<string|int, AllowedType> —A type-sensitive collection of the list's items
unshift()
Prepend the list with an item.
public
unshift(AllowedType $value) : void
Parameters
- $value : AllowedType
-
The item to unshift