class ArrayList extends AbstractList

Represents a List

Traits

Methods

__clone()

No description

__construct(array|Iterator $collection = [])

Creates a new ArrayList

add(...$elements)

No description

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
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

find(...$arguments)

No description

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

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

int|null
findIndex(array ...$arguments)

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

findLast(...$arguments)

No description

int|null
findLastIndex(array ...$arguments)

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

mixed
get(int $index)

Returns the element at the given index (or null if the index isn't present)

int|null
indexOf(mixed $element)

Returns the index of the given element or null if the element can't be found

insert(mixed $element, int|null|string $index)

Insert one element at the given index

bool
isEmpty()

Checks whether this array is empty

key()

No description

map(callable $callback)

Applies the callback to the elements

next()

No description

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

removeByIndex(int $index)

Removes an element from the list by its index.

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 41
__construct(array|Iterator $collection = [])

Creates a new ArrayList

Parameters

array|Iterator $collection

in InsertPart at line 13
abstract add(...$elements)

Parameters

...$elements

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

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 IndexFindersPart at line 13
abstract find(...$arguments)

Parameters

...$arguments

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

at line 126
int|null findIndex(array ...$arguments)

Searches the array with a given callback and returns the index for 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

int|null the index or null if it hasn't been found

in IndexFindersPart at line 15
abstract findLast(...$arguments)

Parameters

...$arguments

at line 103
int|null findLastIndex(array ...$arguments)

Searches the array with a given callback and returns the index for 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

int|null the index or null if it hasn't been found

at line 69
mixed get(int $index)

Returns the element at the given index (or null if the index isn't present)

Parameters

int $index

Return Value

mixed

at line 80
int|null indexOf(mixed $element)

Returns the index of the given element or null if the element can't be found

Parameters

mixed $element

Return Value

int|null the index for the given element

in InsertPart at line 23
InsertPart insert(mixed $element, int|null|string $index)

Insert one element at the given index

Parameters

mixed $element
int|null|string $index

Return Value

InsertPart

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()

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

at line 54
ArrayList removeByIndex(int $index)

Removes an element from the list by its index.

Parameters

int $index

Return Value

ArrayList

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