AbstractLazyCollection
in package
implements
Collection
Lazy collection that is backed by a concrete collection
Tags
Table of Contents
Interfaces
- Collection
- The missing (SPL) Collection/Array/OrderedMap interface.
Properties
- $collection : Collection<string|int, mixed>|null
- The backed collection to use
- $initialized : bool
Methods
- add() : true
- Adds an element at the end of the collection.
- clear() : void
- Clears the collection, removing all elements.
- contains() : mixed
- {@inheritDoc}
- containsKey() : mixed
- {@inheritDoc}
- count() : int
- {@inheritDoc}
- current() : mixed
- {@inheritDoc}
- exists() : mixed
- {@inheritDoc}
- filter() : Collection<string|int, mixed>
- Returns all the elements of this collection that satisfy the predicate p.
- first() : mixed
- {@inheritDoc}
- forAll() : mixed
- {@inheritDoc}
- get() : mixed
- {@inheritDoc}
- getIterator() : Traversable<int|string, mixed>
- {@inheritDoc}
- getKeys() : mixed
- {@inheritDoc}
- getValues() : mixed
- {@inheritDoc}
- indexOf() : mixed
- {@inheritDoc}
- isEmpty() : mixed
- {@inheritDoc}
- isInitialized() : bool
- Is the lazy collection already initialized?
- key() : mixed
- {@inheritDoc}
- last() : mixed
- {@inheritDoc}
- map() : mixed
- {@inheritDoc}
- next() : mixed
- {@inheritDoc}
- offsetExists() : bool
- offsetGet() : mixed
- offsetSet() : void
- offsetUnset() : void
- partition() : array<string|int, Collection<string|int, mixed>>
- Partitions this collection in two collections according to a predicate.
- remove() : mixed
- Removes the element at the specified index from the collection.
- removeElement() : bool
- Removes the specified element from the collection, if it is found.
- set() : void
- Sets an element in the collection at the specified key/index.
- slice() : mixed
- {@inheritDoc}
- toArray() : mixed
- {@inheritDoc}
- doInitialize() : void
- Do the initialization logic
- initialize() : void
- Initialize the collection
Properties
$collection
The backed collection to use
protected
Collection<string|int, mixed>|null
$collection
Tags
$initialized
protected
bool
$initialized
= false
Methods
add()
Adds an element at the end of the collection.
public
add(mixed $element) : true
Parameters
- $element : mixed
-
The element to add.
Return values
true —Always TRUE.
clear()
Clears the collection, removing all elements.
public
clear() : void
contains()
{@inheritDoc}
public
contains(mixed $element) : mixed
Parameters
- $element : mixed
Tags
containsKey()
{@inheritDoc}
public
containsKey(mixed $key) : mixed
Parameters
- $key : mixed
count()
{@inheritDoc}
public
count() : int
Return values
intcurrent()
{@inheritDoc}
public
current() : mixed
exists()
{@inheritDoc}
public
exists(Closure $p) : mixed
Parameters
- $p : Closure
filter()
Returns all the elements of this collection that satisfy the predicate p.
public
filter(Closure $p) : Collection<string|int, mixed>
Parameters
- $p : Closure
-
The predicate used for filtering.
Return values
Collection<string|int, mixed> —A collection with the results of the filter operation.
first()
{@inheritDoc}
public
first() : mixed
forAll()
{@inheritDoc}
public
forAll(Closure $p) : mixed
Parameters
- $p : Closure
get()
{@inheritDoc}
public
get(mixed $key) : mixed
Parameters
- $key : mixed
getIterator()
{@inheritDoc}
public
getIterator() : Traversable<int|string, mixed>
Tags
Return values
Traversable<int|string, mixed>getKeys()
{@inheritDoc}
public
getKeys() : mixed
getValues()
{@inheritDoc}
public
getValues() : mixed
indexOf()
{@inheritDoc}
public
indexOf(mixed $element) : mixed
Parameters
- $element : mixed
Tags
isEmpty()
{@inheritDoc}
public
isEmpty() : mixed
isInitialized()
Is the lazy collection already initialized?
public
isInitialized() : bool
Tags
Return values
boolkey()
{@inheritDoc}
public
key() : mixed
last()
{@inheritDoc}
public
last() : mixed
map()
{@inheritDoc}
public
map(Closure $func) : mixed
Parameters
- $func : Closure
next()
{@inheritDoc}
public
next() : mixed
offsetExists()
public
offsetExists(TKey $offset) : bool
Parameters
- $offset : TKey
Return values
booloffsetGet()
public
offsetGet(TKey $offset) : mixed
Parameters
- $offset : TKey
offsetSet()
public
offsetSet(TKey|null $offset, T $value) : void
Parameters
- $offset : TKey|null
- $value : T
offsetUnset()
public
offsetUnset(TKey $offset) : void
Parameters
- $offset : TKey
partition()
Partitions this collection in two collections according to a predicate.
public
partition(Closure $p) : array<string|int, Collection<string|int, mixed>>
Parameters
- $p : Closure
-
The predicate on which to partition.
Return values
array<string|int, Collection<string|int, mixed>> —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.
remove()
Removes the element at the specified index from the collection.
public
remove(mixed $key) : mixed
Parameters
- $key : mixed
-
The key/index of the element to remove.
Return values
mixed —The removed element or NULL, if the collection did not contain the element.
removeElement()
Removes the specified element from the collection, if it is found.
public
removeElement(mixed $element) : bool
Parameters
- $element : mixed
-
The element to remove.
Return values
bool —TRUE if this collection contained the specified element, FALSE otherwise.
set()
Sets an element in the collection at the specified key/index.
public
set(mixed $key, mixed $value) : void
Parameters
- $key : mixed
-
The key/index of the element to set.
- $value : mixed
-
The element to set.
slice()
{@inheritDoc}
public
slice(mixed $offset[, mixed $length = null ]) : mixed
Parameters
- $offset : mixed
- $length : mixed = null
toArray()
{@inheritDoc}
public
toArray() : mixed
doInitialize()
Do the initialization logic
protected
abstract doInitialize() : void
initialize()
Initialize the collection
protected
initialize() : void