DoubleEndedQueue
class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface (View source)
This class provides a basic implementation of DoubleEndedQueueInterface
, 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. | from 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.
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.
Ensures that the specified element is inserted at the front of this queue.
Ensures that the specified element in inserted at the end of this queue.
Inserts the specified element at the front this queue.
Inserts the specified element at the end this queue.
Retrieves and removes the head of this queue.
Retrieves and removes the tail of this queue.
Retrieves and removes the head of this queue, or returns null
if this
queue is empty.
Retrieves and removes the tail of this queue, or returns null
if this
queue is empty.
Retrieves, but does not remove, the head of this queue.
Retrieves, but does not remove, the tail of this queue.
Retrieves, but does not remove, the head of this queue, or returns null
if this queue is empty.
Retrieves, but does not remove, the tail of this queue, or returns null
if this queue is empty.
Details
__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 48
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
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.
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.
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.
mixed|null
peek()
Retrieves, but does not remove, the head of this queue, or returns null
if this queue is empty.
mixed|null
poll()
Retrieves and removes the head of this queue, or returns null
if this queue is empty.
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 74
bool
addFirst(mixed $element)
Ensures that the specified element is inserted at the front of this queue.
at line 102
bool
addLast(mixed $element)
Ensures that the specified element in inserted at the end of this queue.
at line 116
bool
offerFirst(mixed $element)
Inserts the specified element at the front this queue.
at line 135
bool
offerLast(mixed $element)
Inserts the specified element at the end this queue.
at line 153
mixed
removeFirst()
Retrieves and removes the head of this queue.
This method differs from pollFirst()
only in that it throws an
exception if this queue is empty.
at line 170
mixed
removeLast()
Retrieves and removes the tail of this queue.
This method differs from pollLast()
only in that it throws an exception
if this queue is empty.
at line 192
mixed|null
pollFirst()
Retrieves and removes the head of this queue, or returns null
if this
queue is empty.
at line 205
mixed|null
pollLast()
Retrieves and removes the tail of this queue, or returns null
if this
queue is empty.
at line 232
mixed
firstElement()
Retrieves, but does not remove, the head of this queue.
This method differs from peekFirst()
only in that it throws an
exception if this queue is empty.
at line 249
mixed
lastElement()
Retrieves, but does not remove, the tail of this queue.
This method differs from peekLast()
only in that it throws an exception
if this queue is empty.
at line 267
mixed|null
peekFirst()
Retrieves, but does not remove, the head of this queue, or returns null
if this queue is empty.
at line 280
mixed|null
peekLast()
Retrieves, but does not remove, the tail of this queue, or returns null
if this queue is empty.