MIOLO20
|
Membros públicos | |
add ($element) | |
clear () | |
contains ($element) | |
isEmpty () | |
remove ($key) | |
removeElement ($element) | |
containsKey ($key) | |
get ($key) | |
getKeys () | |
getValues () | |
set ($key, $value) | |
toArray () | |
first () | |
last () | |
key () | |
current () | |
next () | |
exists (Closure $p) | |
filter (Closure $p) | |
forAll (Closure $p) | |
map (Closure $func) | |
partition (Closure $p) | |
indexOf ($element) | |
slice ($offset, $length=null) | |
The missing (SPL) Collection/Array/OrderedMap interface.
A Collection resembles the nature of a regular PHP array. That is, it is essentially an ordered map that can also be used like a list.
A Collection has an internal iterator just like a PHP array. In addition, a Collection can be iterated with external iterators, which is preferrable. To use an external iterator simply use the foreach language construct to iterate over the collection (which calls getIterator()
internally) or explicitly retrieve an iterator though getIterator()
which can then be used to iterate over the collection. You can not rely on the internal iterator of the collection being at a certain position unless you explicitly positioned it before. Prefer iteration with external iterators.
Definido na linha 46 do ficheiro Collection.php.
add | ( | $element | ) |
Adds an element at the end of the collection.
mixed | $element | The element to add. |
Implementado em ArrayCollection.
clear | ( | ) |
Clears the collection, removing all elements.
Implementado em ArrayCollection.
contains | ( | $element | ) |
Checks whether an element is contained in the collection. This is an O(n) operation, where n is the size of the collection.
mixed | $element | The element to search for. |
Implementado em ArrayCollection.
containsKey | ( | $key | ) |
Checks whether the collection contains an element with the specified key/index.
string | integer | $key | The key/index to check for. |
Implementado em ArrayCollection.
current | ( | ) |
Gets the element of the collection at the current iterator position.
Implementado em ArrayCollection.
exists | ( | Closure | $p | ) |
Tests for the existence of an element that satisfies the given predicate.
Closure | $p | The predicate. |
Implementado em ArrayCollection.
filter | ( | Closure | $p | ) |
Returns all the elements of this collection that satisfy the predicate p. The order of the elements is preserved.
Closure | $p | The predicate used for filtering. |
Implementado em ArrayCollection.
first | ( | ) |
Sets the internal iterator to the first element in the collection and returns this element.
Implementado em ArrayCollection.
forAll | ( | Closure | $p | ) |
Applies the given predicate p to all elements of this collection, returning true, if the predicate yields true for all elements.
Closure | $p | The predicate. |
Implementado em ArrayCollection.
get | ( | $key | ) |
Gets the element at the specified key/index.
string | integer | $key | The key/index of the element to retrieve. |
Implementado em ArrayCollection.
getKeys | ( | ) |
Gets all keys/indices of the collection.
Implementado em ArrayCollection.
getValues | ( | ) |
Gets all values of the collection.
Implementado em ArrayCollection.
indexOf | ( | $element | ) |
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.
mixed | $element | The element to search for. |
Implementado em ArrayCollection.
isEmpty | ( | ) |
Checks whether the collection is empty (contains no elements).
Implementado em ArrayCollection.
key | ( | ) |
Gets the key/index of the element at the current iterator position.
Implementado em ArrayCollection.
last | ( | ) |
Sets the internal iterator to the last element in the collection and returns this element.
Implementado em ArrayCollection.
map | ( | Closure | $func | ) |
Applies the given function to each element in the collection and returns a new collection with the elements returned by the function.
Closure | $func |
Implementado em ArrayCollection.
next | ( | ) |
Moves the internal iterator position to the next element.
Implementado em ArrayCollection.
partition | ( | Closure | $p | ) |
Partitions this collection in two collections according to a predicate. Keys are preserved in the resulting collections.
Closure | $p | The predicate on which to partition. |
Implementado em ArrayCollection.
remove | ( | $key | ) |
Removes the element at the specified index from the collection.
string | integer | $key | The kex/index of the element to remove. |
Implementado em ArrayCollection.
removeElement | ( | $element | ) |
Removes the specified element from the collection, if it is found.
mixed | $element | The element to remove. |
Implementado em ArrayCollection.
set | ( | $key, | |
$value ) |
Sets an element in the collection at the specified key/index.
string | integer | $key | The key/index of the element to set. |
mixed | $value | The element to set. |
Implementado em ArrayCollection.
slice | ( | $offset, | |
$length = null ) |
Extract 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.
int | $offset | |
int | $length |
Implementado em ArrayCollection.
toArray | ( | ) |
Gets a native PHP array representation of the collection.
Implementado em ArrayCollection.