This library ports the Java Collections Framework to PHP.
composer require tebru/php-collections
Collections provide data storage where order and random access do not
matter. All collections implement CollectionInterface
.
This is an abstract class that implements the methods it can. It defers the decision of what underlying data structure to use to the concrete implementation.
This is an implementation of CollectionInterface
that extends from
AbstractCollection
and uses an array as data storage.
This inherits from AbstractCollection
and implements the ListInterface
.
Lists add random access to collections. The allow getting/setting/removing
at a specific index. By default, they add elements to the end of the list.
This is an implementation of CollectionInterface
and ListInterface
.
It extends from AbstractList
and uses an array as data storage.
This extends from AbstractCollection
and implements SetInterface
. Sets
differ from generic collections by only allowing one of each element.
This is an implementation of CollectionInterface
and SetInterface
and
extends from AbstractSet
. This uses a HashMap
as data storage.
Maps provide data storage where order does not matter, but the ability to
get a value by key is important. All maps implement MapInterface
.
This implements MapInterface
and implements any methods that do not
need to know about the specific data storage.
This is an implementation of MapInterface
and extends from
AbstractMap
. It uses an array as data storage.