Download the PHP package nsilbernagel/accumulatephp without Composer
On this page you can find all versions of the php package nsilbernagel/accumulatephp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nsilbernagel/accumulatephp
More information about nsilbernagel/accumulatephp
Files in nsilbernagel/accumulatephp
Package accumulatephp
Short Description A PHP collections (accumulations) framework.
License MIT
Informations about the package accumulatephp
Development happens at AccumulatePHP-src
AccumulatePHP
A PHP collections library, inspired by java collections framework.
What is this library for
Using more refined datastructures allows for safer, often more efficient code than using arrays (list and assoc). TreeMap for example guarantees being searchable in O (log n). Furthermore, non-scalar keys can be used as keys in maps.
Static Analysis
AccumulatePHP provides first class support for static analysis through PHPStan level 9.
Installation
Usage Examples
ArraySeries and HashMap are the main two data structures you will be using. Here are examples of how to use them.
ArraySeries
For a complete overview of ArraySeries and the other series available, please refer to the source files under src/series
HashMap
Hashmaps can use any type keys, except for resources and arrays. Classes may implement Hashable interface to determine their hash function and definition of equality. You may refer to https://www.baeldung.com/java-equals-hashcode-contracts to learn more about equals and hashcode and their contracts.
Helpers
AccumulatePHP provides helper methods for creating Accumulations
Structure
Accumulation
The base interface of this library. An accumulation (collection) of items. Iterable and Countable.
SequencedAccumulation
An Accumulation with a defined sequence or order of elements. Which order this is is up to the implementation. It might be insertion order for some or natural order for others.
Series
A SequencedAccumulation that allows getting by index, mapping, filtering etc.
MutableSeries
Like the Series but with methods for mutation.
ArraySeries
Basic array implementation of a MutableSeries
Map
A readonly key-value mapping. Can be created from and converted to associative arrays, will lose any non-scalar keys during conversion. Iterable over its entry objects. It is up to the implementation what type of keys are supported. It is strongly recommended to only use the same type of key for a map (can be enforced through static analysis tools).
Entry
An entry of a map.
SequencedMap
A Map with defined Order of keys
MutableMap
Like Map but with methods for mutation.
SequencedMap
A Map with defined Order of keys
HashMap
A Hashtable-like map implementation.
TreeMap
A Red-Black Tree SequencedMap implementation. Keys are ordered by their natural order (spaceship operator) by default.
Set
An accumulation where every element may only exist once
MutableSet
Like Set but with methods for mutation
SequencedSet
A Set with defined Order of keys
HashSet
Hash implementation of a Set. Uses HashMap in the background.
StrictSet
A Set implementation using php strict comparison.