| Methods |
public
|
contains<TMaybeContained>(TMaybeContained $element): bool
Checks whether an element is contained in the collection.
This is an O(n) operation, where n is the size of the…
Checks whether an element is contained in the collection.
This is an O(n) operation, where n is the size of the collection.
Returns
TRUE if the collection contains the element, FALSE otherwise.
Implemented by
|
#
|
public
|
isEmpty(): bool
Checks whether the collection is empty (contains no elements).
Checks whether the collection is empty (contains no elements).
Returns
TRUE if the collection is empty, FALSE otherwise.
Implemented by
|
#
|
public
|
containsKey(TKey $key): bool
Checks whether the collection contains an element with the specified key/index.
Checks whether the collection contains an element with the specified key/index.
Returns
TRUE if the collection contains an element with the specified key/index,
FALSE otherwise.
Implemented by
|
#
|
public
|
get(TKey $key): mixed
Gets the element at the specified key/index.
Gets the element at the specified key/index.
Implemented by
|
#
|
public
|
getKeys(): int[]|string[]
Gets all keys/indices of the collection.
Gets all keys/indices of the collection.
Returns
The keys/indices of the collection, in the order of the corresponding
elements in the collection.
Implemented by
|
#
|
public
|
getValues(): mixed[]
Gets all values of the collection.
Gets all values of the collection.
Returns
The values of all elements in the collection, in the
order they appear in the collection.
Implemented by
|
#
|
public
|
toArray(): mixed[]
Gets a native PHP array representation of the collection.
Gets a native PHP array representation of the collection.
Implemented by
|
#
|
public
|
first(): mixed
Sets the internal iterator to the first element in the collection and returns this element.
Sets the internal iterator to the first element in the collection and returns this element.
Implemented by
|
#
|
public
|
last(): mixed
Sets the internal iterator to the last element in the collection and returns this element.
Sets the internal iterator to the last element in the collection and returns this element.
Implemented by
|
#
|
public
|
key(): int|string|null
Gets the key/index of the element at the current iterator position.
Gets the key/index of the element at the current iterator position.
Implemented by
|
#
|
public
|
current(): mixed
Gets the element of the collection at the current iterator position.
Gets the element of the collection at the current iterator position.
Implemented by
|
#
|
public
|
next(): mixed
Moves the internal iterator position to the next element and returns this element.
Moves the internal iterator position to the next element and returns this element.
Implemented by
|
#
|
public
|
slice(int $offset, int|null $length = null): mixed[]
Extracts a slice of $length elements starting at position $offset from the Collection.
Extracts a slice of $length elements starting at position $offset from the Collection.
If $length is null it returns all elements from $offset to the end of the Collection.
Keys have to be preserved by this method. Calling this method will only return the
selected slice and NOT change the elements contained in the collection slice is called on.
Parameters
| $offset |
The offset to start from.
|
| $length |
The maximum number of elements to return, or null for no limit.
|
Implemented by
|
#
|
public
|
exists(Closure(TKey, T): bool $p): bool
Tests for the existence of an element that satisfies the given predicate.
Tests for the existence of an element that satisfies the given predicate.
Returns
TRUE if the predicate is TRUE for at least one element, FALSE otherwise.
Implemented by
|
#
|
public
|
filter(Closure(T, TKey): bool $p): ReadableCollection<mixed>
Returns all the elements of this collection that satisfy the predicate p.
The order of the elements is preserved.
Returns all the elements of this collection that satisfy the predicate p.
The order of the elements is preserved.
Returns
A collection with the results of the filter operation.
Implemented by
|
#
|
public
|
map<U>(Closure(T): U $func): ReadableCollection<mixed>
Applies the given function to each element in the collection and returns
a new collection with the elements returned by…
Applies the given function to each element in the collection and returns
a new collection with the elements returned by the function.
Implemented by
|
#
|
public
|
partition(Closure(TKey, T): bool $p): ReadableCollection<mixed>[]
Partitions this collection in two collections according to a predicate.
Keys are preserved in the resulting collections.
Partitions this collection in two collections according to a predicate.
Keys are preserved in the resulting collections.
Returns
An array with two elements. The first element contains the collection
of elements where the predicate returned TRUE, the second element
contains the collection of elements where the predicate returned FALSE.
Implemented by
|
#
|
public
|
forAll(Closure(TKey, T): bool $p): bool
Tests whether the given predicate p holds for all elements of this collection.
Tests whether the given predicate p holds for all elements of this collection.
Returns
TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.
Implemented by
|
#
|
public
|
indexOf<TMaybeContained>(TMaybeContained $element): int|string|bool
Gets the index/key of a given element. The comparison of two elements is strict,
that means not only the value but also…
Gets the index/key of a given element. The comparison of two elements is strict,
that means not only the value but also the type must match.
For objects this means reference equality.
Returns
The key/index of the element or FALSE if the element was not found.
Implemented by
|
#
|
public
|
findFirst(Closure(TKey, T): bool $p): mixed
Returns the first element of this collection that satisfies the predicate p.
Returns the first element of this collection that satisfies the predicate p.
Returns
The first element respecting the predicate,
null if no element respects the predicate.
Implemented by
|
#
|
public
|
reduce<TReturn, TInitial>(
Closure(TReturn|TInitial|null, T): (TInitial|TReturn) $func,
TInitial|null $initial = null,
): mixed
Applies iteratively the given function to each element in the collection,
so as to reduce the collection to a single…
Applies iteratively the given function to each element in the collection,
so as to reduce the collection to a single value.
Implemented by
|
#
|