class Queue extends AbstractList

Represents a Queue

FIFO - first in first out

Traits

Methods

__clone()

No description

__construct(array|Iterator $collection = [])

Creates a new Queue

void
clear()

Remove all elements from the collection.

bool
contains(mixed $element)

Checks whether the given element is in this array

int
count()

Counts the array

current()

No description

void
each(callable $callback)

Iterates the array and calls the callback function with the current item as parameter

from EachPart
enqueue(mixed ...$elements)

Enqueues an element

bool
every(callable $callback)

Tests whether all elements in the array pass the test implemented by the provided function.

filter(callable $callback)

Filters elements using a callback function

mixed|null
find(array ...$arguments)

Searches the array with a given callback and returns the first element if found.

mixed|null
findAll(array ...$arguments)

Searches the array with a given callback and returns all matching elements.

mixed|null
findLast(array ...$arguments)

Searches the array with a given callback and returns the last element if found.

bool
isEmpty()

Checks whether this array is empty

key()

No description

map(callable $callback)

Applies the callback to the elements

next()

No description

mixed
peek()

Returns the element at the head or null if the queue is empty but doesn't remove that element

mixed
poll()

Removes and returns the element at the head or null if the is empty

mixed
reduce(callable $callback, mixed $fallback = null)

Iterative reduction of this array or collection with the help of a callback function. The callback function takes two parameters, the first is the carry, the second the current item, with this signature: mixed callback(mixed $carry, mixed $item)

remove(mixed ...$elements)

Removes one or more elements from the array

reverse()

Reverses the order of all elements

reverseSort(Comparator|callable $cmp = null)

Sorts the collection in reverse order

rewind()

No description

bool
search(array ...$arguments)

Searches the array for query using the callback function on each element

int
size()

Return the size of the array.

bool
some(callable $callback)

Tests whether at least one element in the array passes the test implemented by the provided function.

sort(Comparator|callable $cmp = null)

Sorts the array

array
toArray()

Returns the php array type

bool
valid()

No description

Details

in AbstractArray at line 44
__clone()

at line 28
__construct(array|Iterator $collection = [])

Creates a new Queue

Parameters

array|Iterator $collection

in AbstractCollection at line 24
void clear()

Remove all elements from the collection.

Return Value

void

in AbstractArray at line 55
bool contains(mixed $element)

Checks whether the given element is in this array

Parameters

mixed $element

Return Value

bool

in AbstractArray at line 30
int count()

Counts the array

Return Value

int the amount of items

in AbstractCollection at line 38
current()

in EachPart at line 19
void each(callable $callback)

Iterates the array and calls the callback function with the current item as parameter

Parameters

callable $callback

Return Value

void

at line 39
Queue enqueue(mixed ...$elements)

Enqueues an element

Parameters

mixed ...$elements

Return Value

Queue

in AbstractArray at line 246
bool every(callable $callback)

Tests whether all elements in the array pass the test implemented by the provided function.

Returns true for an empty array.

Parameters

callable $callback

Return Value

bool

in AbstractArray at line 280
AbstractArray filter(callable $callback)

Filters elements using a callback function

Parameters

callable $callback the filter function

Return Value

AbstractArray

in AbstractArray at line 85
mixed|null find(array ...$arguments)

Searches the array with a given callback and returns the first element if found.

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- find($query, callback)
- find(callback)

Parameters

array ...$arguments

Return Value

mixed|null the found element or null if it hasn't been found

in AbstractArray at line 144
mixed|null findAll(array ...$arguments)

Searches the array with a given callback and returns all matching elements.

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- find($query, callback)
- find(callback)

Parameters

array ...$arguments

Return Value

mixed|null the found element or null if it hasn't been found

in AbstractArray at line 114
mixed|null findLast(array ...$arguments)

Searches the array with a given callback and returns the last element if found.

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- find($query, callback)
- find(callback)

Parameters

array ...$arguments

Return Value

mixed|null the found element or null if it hasn't been found

in AbstractArray at line 64
bool isEmpty()

Checks whether this array is empty

Return Value

bool

in AbstractCollection at line 45
key()

in AbstractArray at line 291
AbstractArray map(callable $callback)

Applies the callback to the elements

Parameters

callable $callback the applied callback function

Return Value

AbstractArray

in AbstractCollection at line 52
next()

at line 53
mixed peek()

Returns the element at the head or null if the queue is empty but doesn't remove that element

Return Value

mixed

at line 66
mixed poll()

Removes and returns the element at the head or null if the is empty

Return Value

mixed

in ReducePart at line 24
mixed reduce(callable $callback, mixed $fallback = null)

Iterative reduction of this array or collection with the help of a callback function. The callback function takes two parameters, the first is the carry, the second the current item, with this signature: mixed callback(mixed $carry, mixed $item)

Parameters

callable $callback the callback function
mixed $fallback the default value, that will be returned when the list is empty

Return Value

mixed

in RemovePart at line 20
RemovePart remove(mixed ...$elements)

Removes one or more elements from the array

Parameters

mixed ...$elements

Return Value

RemovePart

in ReversePart at line 19
ReversePart reverse()

Reverses the order of all elements

Return Value

ReversePart

in AbstractList at line 40
AbstractList reverseSort(Comparator|callable $cmp = null)

Sorts the collection in reverse order

Parameters

Comparator|callable $cmp

Return Value

AbstractList

See also

#sort
#reverse

in AbstractCollection at line 31
rewind()

Searches the array for query using the callback function on each element

The callback function takes one or two parameters:

function ($element [, $query]) {}

The callback must return a boolean When it's passed, $query must be the first argument:

- search($query, callback)
- search(callback)

Parameters

array ...$arguments

Return Value

bool

in AbstractArray at line 40
int size()

Return the size of the array.

Alias of count

Return Value

int

in AbstractArray at line 264
bool some(callable $callback)

Tests whether at least one element in the array passes the test implemented by the provided function.

Returns false for an empty array.

Parameters

callable $callback

Return Value

bool

in AbstractArray at line 202
AbstractArray sort(Comparator|callable $cmp = null)

Sorts the array

Parameters

Comparator|callable $cmp

Return Value

AbstractArray

in AbstractArray at line 191
array toArray()

Returns the php array type

Return Value

array

in AbstractCollection at line 59
bool valid()

Return Value

bool