abstract class AbstractLazyCollection in Plug 7
Lazy collection that is backed by a concrete collection
@author Michaël Gallego <mic.gallego@gmail.com> @since 1.2
Hierarchy
- class \Doctrine\Common\Collections\AbstractLazyCollection implements Collection
Expanded class hierarchy of AbstractLazyCollection
1 file declares its use of AbstractLazyCollection
- LazyArrayCollection.php in lib/
doctrine/ collections/ tests/ Doctrine/ Tests/ LazyArrayCollection.php
File
- lib/
doctrine/ collections/ lib/ Doctrine/ Common/ Collections/ AbstractLazyCollection.php, line 30
Namespace
Doctrine\Common\CollectionsView source
abstract class AbstractLazyCollection implements Collection {
/**
* The backed collection to use
*
* @var Collection
*/
protected $collection;
/**
* @var boolean
*/
protected $initialized = false;
/**
* {@inheritDoc}
*/
public function count() {
$this
->initialize();
return $this->collection
->count();
}
/**
* {@inheritDoc}
*/
public function add($element) {
$this
->initialize();
return $this->collection
->add($element);
}
/**
* {@inheritDoc}
*/
public function clear() {
$this
->initialize();
$this->collection
->clear();
}
/**
* {@inheritDoc}
*/
public function contains($element) {
$this
->initialize();
return $this->collection
->contains($element);
}
/**
* {@inheritDoc}
*/
public function isEmpty() {
$this
->initialize();
return $this->collection
->isEmpty();
}
/**
* {@inheritDoc}
*/
public function remove($key) {
$this
->initialize();
return $this->collection
->remove($key);
}
/**
* {@inheritDoc}
*/
public function removeElement($element) {
$this
->initialize();
return $this->collection
->removeElement($element);
}
/**
* {@inheritDoc}
*/
public function containsKey($key) {
$this
->initialize();
return $this->collection
->containsKey($key);
}
/**
* {@inheritDoc}
*/
public function get($key) {
$this
->initialize();
return $this->collection
->get($key);
}
/**
* {@inheritDoc}
*/
public function getKeys() {
$this
->initialize();
return $this->collection
->getKeys();
}
/**
* {@inheritDoc}
*/
public function getValues() {
$this
->initialize();
return $this->collection
->getValues();
}
/**
* {@inheritDoc}
*/
public function set($key, $value) {
$this
->initialize();
$this->collection
->set($key, $value);
}
/**
* {@inheritDoc}
*/
public function toArray() {
$this
->initialize();
return $this->collection
->toArray();
}
/**
* {@inheritDoc}
*/
public function first() {
$this
->initialize();
return $this->collection
->first();
}
/**
* {@inheritDoc}
*/
public function last() {
$this
->initialize();
return $this->collection
->last();
}
/**
* {@inheritDoc}
*/
public function key() {
$this
->initialize();
return $this->collection
->key();
}
/**
* {@inheritDoc}
*/
public function current() {
$this
->initialize();
return $this->collection
->current();
}
/**
* {@inheritDoc}
*/
public function next() {
$this
->initialize();
return $this->collection
->next();
}
/**
* {@inheritDoc}
*/
public function exists(Closure $p) {
$this
->initialize();
return $this->collection
->exists($p);
}
/**
* {@inheritDoc}
*/
public function filter(Closure $p) {
$this
->initialize();
return $this->collection
->filter($p);
}
/**
* {@inheritDoc}
*/
public function forAll(Closure $p) {
$this
->initialize();
return $this->collection
->forAll($p);
}
/**
* {@inheritDoc}
*/
public function map(Closure $func) {
$this
->initialize();
return $this->collection
->map($func);
}
/**
* {@inheritDoc}
*/
public function partition(Closure $p) {
$this
->initialize();
return $this->collection
->partition($p);
}
/**
* {@inheritDoc}
*/
public function indexOf($element) {
$this
->initialize();
return $this->collection
->indexOf($element);
}
/**
* {@inheritDoc}
*/
public function slice($offset, $length = null) {
$this
->initialize();
return $this->collection
->slice($offset, $length);
}
/**
* {@inheritDoc}
*/
public function getIterator() {
$this
->initialize();
return $this->collection
->getIterator();
}
/**
* {@inheritDoc}
*/
public function offsetExists($offset) {
$this
->initialize();
return $this->collection
->offsetExists($offset);
}
/**
* {@inheritDoc}
*/
public function offsetGet($offset) {
$this
->initialize();
return $this->collection
->offsetGet($offset);
}
/**
* {@inheritDoc}
*/
public function offsetSet($offset, $value) {
$this
->initialize();
$this->collection
->offsetSet($offset, $value);
}
/**
* {@inheritDoc}
*/
public function offsetUnset($offset) {
$this
->initialize();
$this->collection
->offsetUnset($offset);
}
/**
* Is the lazy collection already initialized?
*
* @return bool
*/
public function isInitialized() {
return $this->initialized;
}
/**
* Initialize the collection
*
* @return void
*/
protected function initialize() {
if (!$this->initialized) {
$this
->doInitialize();
$this->initialized = true;
}
}
/**
* Do the initialization logic
*
* @return void
*/
protected abstract function doInitialize();
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractLazyCollection:: |
protected | property | The backed collection to use | |
AbstractLazyCollection:: |
protected | property | ||
AbstractLazyCollection:: |
public | function |
Adds an element at the end of the collection. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Clears the collection, removing all elements. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Checks whether an element is contained in the collection.
This is an O(n) operation, where n is the size of the collection. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Checks whether the collection contains an element with the specified key/index. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function | ||
AbstractLazyCollection:: |
public | function |
Gets the element of the collection at the current iterator position. Overrides Collection:: |
|
AbstractLazyCollection:: |
abstract protected | function | Do the initialization logic | 1 |
AbstractLazyCollection:: |
public | function |
Tests for the existence of an element that satisfies the given predicate. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Returns all the elements of this collection that satisfy the predicate p.
The order of the elements is preserved. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Sets the internal iterator to the first element in the collection and returns this element. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Tests whether the given predicate p holds for all elements of this collection. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Gets the element at the specified key/index. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function | ||
AbstractLazyCollection:: |
public | function |
Gets all keys/indices of the collection. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Gets all values of the collection. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
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. Overrides Collection:: |
|
AbstractLazyCollection:: |
protected | function | Initialize the collection | |
AbstractLazyCollection:: |
public | function |
Checks whether the collection is empty (contains no elements). Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function | Is the lazy collection already initialized? | |
AbstractLazyCollection:: |
public | function |
Gets the key/index of the element at the current iterator position. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Sets the internal iterator to the last element in the collection and returns this element. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Applies the given function to each element in the collection and returns
a new collection with the elements returned by the function. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Moves the internal iterator position to the next element and returns this element. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function | ||
AbstractLazyCollection:: |
public | function | ||
AbstractLazyCollection:: |
public | function | ||
AbstractLazyCollection:: |
public | function | ||
AbstractLazyCollection:: |
public | function |
Partitions this collection in two collections according to a predicate.
Keys are preserved in the resulting collections. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Removes the element at the specified index from the collection. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Removes the specified element from the collection, if it is found. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Sets an element in the collection at the specified key/index. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Extracts a slice of $length elements starting at position $offset from the Collection. Overrides Collection:: |
|
AbstractLazyCollection:: |
public | function |
Gets a native PHP array representation of the collection. Overrides Collection:: |