StrictQueue
extends StrictList
in package
implements
ArrayAccess, Countable, Iterator, Serializable
A type-sensitive, taversable First In, First Out queue (FIFO).
Extends \SplQueue with an option to specify the allowed data types for list items.
Tags
Table of Contents
Interfaces
- ArrayAccess
- Countable
- Iterator
- Serializable
Properties
- $allowedTypes : array<string|int, string>
Methods
- __construct() : void
- Create a type-sensitive, traversable queue of items.
- add() : void
- Add/insert a new value at the specified offset.
- append() : void
- Append values at the end of the list.
- bottom() : AllowedType
- Peek at the value at the beginning of the list.
- dequeue() : AllowedType
- Dequeue an item from the queue.
- enqueue() : void
- Add an item to the queue.
- getAllowedTypes() : array<string|int, string>
- Get allowed data types for list values.
- getIteratorMode() : int
- Get the mode of iteration.
- isAllowedType() : bool
- Check if the value's data type is allowed on the list.
- offsetSet() : void
- Set the value at the specified offset.
- pop() : AllowedType
- Pops an value from the end of the list.
- prepend() : void
- Prepend values at the start of the list.
- push() : void
- Push an value at the end of the list.
- setIteratorMode() : int
- Set the mode of iteration.
- shift() : AllowedType
- Shift an value from the beginning of the list.
- top() : AllowedType
- Peek at the value at the end of the list.
- unshift() : void
- Prepend the list with an value.
- setAllowedTypes() : void
- Set allowed data types of list values.
Properties
$allowedTypes read-only
public
array<string|int, string>
$allowedTypes
The allowed data types for values.
Methods
__construct()
Create a type-sensitive, traversable queue 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 value at the specified offset.
public
add(int $offset, AllowedType $value) : void
Parameters
- $offset : int
-
The offset where the new value is to be inserted
- $value : AllowedType
-
The new value for the offset
Tags
append()
Append values at the end of the list.
public
append(AllowedType ...$values) : void
Parameters
- $values : AllowedType
-
One or more values to append
Tags
bottom()
Peek at the value at the beginning of the list.
public
bottom() : AllowedType
Tags
Return values
AllowedType —The first value of the list
dequeue()
Dequeue an item from the queue.
public
dequeue() : AllowedType
Return values
AllowedType —The dequeued item
enqueue()
Add an item to the queue.
public
enqueue(AllowedType $item) : void
Parameters
- $item : AllowedType
-
The item to enqueue
Tags
getAllowedTypes()
Get allowed data types for list values.
public
getAllowedTypes() : array<string|int, string>
Return values
array<string|int, string> —The list of allowed data types
getIteratorMode()
Get the mode of iteration.
public
getIteratorMode() : int
Return values
int —The set of flags and modes of iteration
isAllowedType()
Check if the value's data type is allowed on the list.
public
isAllowedType(AllowedType $value) : bool
Parameters
- $value : AllowedType
-
The value to check
Return values
bool —Whether the value's data type is allowed
offsetSet()
Set the value 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 value for the offset
Tags
pop()
Pops an value from the end of the list.
public
pop() : AllowedType
Tags
Return values
AllowedType —The value from the end of the list
prepend()
Prepend values at the start of the list.
public
prepend(AllowedType ...$values) : void
Parameters
- $values : AllowedType
-
One or more values to prepend
Tags
push()
Push an value at the end of the list.
public
push(AllowedType $value) : void
Parameters
- $value : AllowedType
-
The value to push
Tags
setIteratorMode()
Set the mode of iteration.
public
final setIteratorMode(int $mode) : int
Parameters
- $mode : int
-
The new iterator mode (0 or 1)
There are two orthogonal sets of modes that can be set.
The direction of iteration (fixed for StrictQueue):
- StrictQueue::IT_MODE_FIFO (queue style)
The behavior of the iterator (either one or the other):
- StrictQueue::IT_MODE_DELETE (delete items)
- StrictQueue::IT_MODE_KEEP (keep items)
The default mode is: IT_MODE_FIFO | IT_MODE_KEEP
Tags
Return values
int —The set of flags and modes of iteration
shift()
Shift an value from the beginning of the list.
public
shift() : AllowedType
Tags
Return values
AllowedType —The first value of the list
top()
Peek at the value at the end of the list.
public
top() : AllowedType
Tags
Return values
AllowedType —The last value of the list
unshift()
Prepend the list with an value.
public
unshift(AllowedType $value) : void
Parameters
- $value : AllowedType
-
The value to unshift
Tags
setAllowedTypes()
Set allowed data types of list values.
protected
setAllowedTypes([array<string|int, string> $allowedTypes = [] ]) : void
Parameters
- $allowedTypes : array<string|int, string> = []
-
Allowed data types of values