Queue
class Queue extends AbstractArray implements QueueInterface (View source)
This class provides a basic implementation of QueueInterface
, to minimize
the effort required to implement this interface.
Traits
Properties
protected array | $data | The items of this array. | from AbstractArray |
protected int | $index | The index of the head of the queue. |
Methods
Constructs a queue object of the specified type, optionally with the specified data.
Returns true
if the given offset exists in this array.
Sets the given value to the given offset in the queue.
Removes the given offset and its value from the array.
Returns a serialized string representation of this array object.
Converts a serialized string representation into an instance object.
Returns true
if value is of the specified type.
Returns a string representation of the value.
Ensures that this queue contains the specified element.
Retrieves, but does not remove, the head of this queue.
Inserts the specified element into this queue.
Retrieves, but does not remove, the head of this queue, or returns null
if this queue is empty.
Retrieves and removes the head of this queue, or returns null
if this queue is empty.
Retrieves and removes the head of this queue.
Returns the type associated with this queue.
Details
at line 55
__construct(string $queueType, array $data = [])
Constructs a queue object of the specified type, optionally with the specified data.
in AbstractArray at line 51
Traversable
getIterator()
Returns an iterator for this array.
in AbstractArray at line 65
bool
offsetExists(mixed $offset)
Returns true
if the given offset exists in this array.
in AbstractArray at line 80
mixed|null
offsetGet(mixed $offset)
Returns the value at the specified offset.
at line 76
void
offsetSet(mixed|null $offset, mixed $value)
Sets the given value to the given offset in the queue.
Since arbitrary offsets may not be manipulated in a queue, this method
serves only to fulfill the ArrayAccess
interface requirements. It is
invoked by other operations when adding values to the queue.
in AbstractArray at line 110
void
offsetUnset(mixed $offset)
Removes the given offset and its value from the array.
in AbstractArray at line 122
string
serialize()
Returns a serialized string representation of this array object.
in AbstractArray at line 134
void
unserialize(string $serialized)
Converts a serialized string representation into an instance object.
in AbstractArray at line 146
int
count()
Returns the number of items in this array.
in AbstractArray at line 154
void
clear()
Removes all items from this array.
in AbstractArray at line 164
array
toArray()
Returns a native PHP array representation of this array object.
in AbstractArray at line 174
bool
isEmpty()
Returns true
if this array is empty.
protected bool
checkType(string $type, mixed $value)
Returns true
if value is of the specified type.
in ValueToStringTrait at line 38
protected string
toolValueToString(mixed $value)
Returns a string representation of the value.
- null value:
'NULL'
- boolean:
'TRUE'
,'FALSE'
- array:
'Array'
- scalar: converted-value
- resource:
'(type resource #number)'
- object with
__toString()
: result of__toString()
- object DateTime: ISO 8601 date
- object:
'(className Object)'
- anonymous function: same as object
at line 103
bool
add(mixed $element)
Ensures that this queue contains the specified element.
This method differs from offer()
only in that it throws an exception if
it cannot add the element to the queue.
at line 122
mixed
element()
Retrieves, but does not remove, the head of this queue.
This method differs from peek()
only in that it throws an exception if
this queue is empty.
at line 145
bool
offer(mixed $element)
Inserts the specified element into this queue.
This method differs from add()
only in that it does not throw an
exception if it cannot add the element to the queue.
at line 162
mixed|null
peek()
Retrieves, but does not remove, the head of this queue, or returns null
if this queue is empty.
at line 179
mixed|null
poll()
Retrieves and removes the head of this queue, or returns null
if this queue is empty.
at line 205
mixed
remove()
Retrieves and removes the head of this queue.
This method differs from poll()
only in that it throws an exception if
this queue is empty.
at line 224
string
getType()
Returns the type associated with this queue.