A list of values of any type.
- Class name: ArrayList
- Namespace: PHPCollections\Collections
- This class implements: CollectionInterface, IterableInterface, MergeableInterface, SortableInterface
void PHPCollections\Collections\ArrayList::add(mixed $value)
Adds a new element to the collection.
- Visibility: public
- $value mixed
ArrayList PHPCollections\Collections\ArrayList::diff(ArrayList $newArrayList)
Gets the difference between two ArrayList.
- Visibility: public
- $newArrayList \PHPCollections\Collections\ArrayList
- \PHPCollections\Exceptions\InvalidOperationException
boolean PHPCollections\Collections\ArrayList::equals(ArrayList $collection)
Determines if two ArrayList objects are equal.
- Visibility: public
- $collection \PHPCollections\Collections\ArrayList
- \PHPCollections\Exceptions\InvalidOperationException
?ArrayList PHPCollections\Collections\ArrayList::filter(callable $callback)
Returns all the coincidences found for the given callback or null.
- Visibility: public
- $callback callable
void PHPCollections\Collections\ArrayList::forEach(callable $callback)
Iterates over every element of the collection.
- Visibility: public
- $callback callable
mixed PHPCollections\Collections\ArrayList::get(integer $offset)
Gets the element specified at the given index.
- Visibility: public
- $offset integer
?ArrayList PHPCollections\Collections\ArrayList::map(callable $callback)
Updates elements in the collection by applying a given callback function.
- Visibility: public
- $callback callable
ArrayList PHPCollections\Collections\ArrayList::merge(ArrayList $newArrayList)
Merges two ArrayList into a new one.
- Visibility: public
- $newArrayList \PHPCollections\Collections\ArrayList
mixed PHPCollections\Collections\ArrayList::rand()
Returns a random element of the collection.
- Visibility: public
- \PHPCollections\Exceptions\InvalidOperationException
void PHPCollections\Collections\ArrayList::remove(integer $offset)
Removes an item from the collection and repopulates the data array.
- Visibility: public
- $offset integer
- \OutOfRangeException
ArrayList PHPCollections\Collections\ArrayList::reverse()
Returns a new collection with the reversed values.
- Visibility: public
- \PHPCollections\Exceptions\InvalidOperationException
?ArrayList PHPCollections\Collections\ArrayList::slice(int $offset, ?int $length = null)
Returns a portion of the ArrayList.
- Visibility: public
- $offset int
- $length int
?ArrayList PHPCollections\Collections\ArrayList::sort(callable $callback)
Returns a new ArrayList with the values ordered by a given callback if couldn't sort returns null.
- Visibility: public
- $callback callable
bool PHPCollections\Collections\ArrayList::update(integer $index, mixed $value)
Updates the value of the element at the given index.
- Visibility: public
- $index integer
- $value mixed