Package io.vavr.collection
package io.vavr.collection
Purely functional collections based on Traversable.
Performance Characteristics of Vavr Collections
| head() | tail() | get(int) | update(int, T) | prepend(T) | append(T) | |
|---|---|---|---|---|---|---|
| Array | const | linear | const | linear | linear | linear |
| CharSeq | const | linear | const | linear | linear | linear |
| Iterator | const | const | — | — | — | — |
| List | const | const | linear | linear | const | linear |
| Queue | const | consta | linear | linear | const | const |
| PriorityQueue | log | log | — | — | log | log |
| Stream | const | const | linear | linear | constlazy | constlazy |
| Vector | consteff | consteff | consteff | consteff | consteff | consteff |
| contains/Key | add/put | remove | min | |
|---|---|---|---|---|
| HashMap | consteff | consteff | consteff | linear |
| HashSet | consteff | consteff | consteff | linear |
| LinkedHashMap | consteff | linear | linear | linear |
| LinkedHashSet | consteff | linear | linear | linear |
| Tree | log | log | log | log |
| TreeMap | log | log | log | log |
| TreeSet | log | log | log | log |
- const · constant time
- consta · amortized constant time, few operations may take longer
- consteff · effectively constant time, depending on assumptions like distribution of hash keys
- constlazy · lazy constant time, the operation is deferred
- log · logarithmic time
- linear · linear time
-
ClassDescriptionArray<T>Array is an immutable Traversable wrapper for
Object[]containing elements of typeT.BitSet<T>An immutableBitSetimplementation.Builder of the BitSet.The CharSeq (read: character sequence) collection essentially is a rich String wrapper having all operations we know from the functional Vavr collections.Represents a function that accepts achar-valued argument and produces a result.Represents an operation on a singlechar-valued operand that produces achar-valued result.Foldable<T>Represents a data structure that can be folded (reduced) into a single value.HashMap<K,V> An immutableHashMapimplementation based on a Hash array mapped trie (HAMT).HashMultimap<K,V> Builder for creatingHashMultimapinstances with different container types.HashSet<T>An immutableHashSetimplementation.IndexedSeq<T>Represents an immutable, indexed sequence of elements.Iterator<T>A compositional alternative tojava.util.Iteratordesigned for single-pass traversal of a sequence.LinearSeq<T>Interface for immutable, linear sequences.LinkedHashMap<K,V> An immutableLinkedHashMapimplementation that has predictable (insertion-order) iteration.LinkedHashMultimap<K,V> ALinkedHashMap-based implementation ofMultimapBuilder class for creating LinkedHashMultimap instances.An immutableHashSetimplementation that has predictable (insertion-order) iteration.List<T>An immutableListis an eager sequence of elements.List.Cons<T>Non-emptyList, consisting of aheadand atail.List.Nil<T>Representation of the singleton emptyList.Map<K,V> An immutableMapinterface.Multimap<K,V> An immutableMultimapinterface.Defines the type of container used to store values associated with keys in a Multimap.Ordered<T>A collection whose elements are arranged according to a well-defined order.A PriorityQueue.Queue<T>An immutableQueuestores elements allowing a first-in-first-out (FIFO) retrieval.Seq<T>Base interface for immutable, sequential collections.Set<T>An immutableSetinterface.SortedMap<K,V> An immutableSortedMapinterface.SortedMultimap<K,V> An immutableSortedMultimapinterface.SortedSet<T>An immutableSortedSetinterface.Stream<T>An immutableStreamis lazy sequence of elements which may be infinitely long.Stream.Cons<T>Non-emptyStream, consisting of ahead, andtail.Stream.Empty<T>The empty Stream.Traversable<T>Represents a recursive, multi-valued data structure whose elements can be traversed in order.Tree<T>A general Tree interface.Tree.Empty<T>The empty tree.Tree.Node<T>Represents a tree node.Tree traversal order.TreeMap<K,V> An immutableSortedMapimplementation backed by a Red-Black tree.TreeMultimap<K,V> Builder class for creating TreeMultimap instances.TreeSet<T>SortedSet implementation, backed by a Red/Black Tree.Vector<T>Vector is the default Seq implementation that provides effectively constant time access to any element.