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
-
ClassDescriptionProvides a common
Object.toString()implementation.AnMultimapimplementation (not intended to be public).Array<T>Array is a Traversable wrapper forObject[]containing elements of typeT.ArrayType<T>Helper to replace reflective array access.A `bit-mapped trie` is a very wide and shallow tree (for integer indices the depth will be `≤6`).BitSet<T>An immutableBitSetimplementation.The CharSeq (read: character sequence) collection essentially is a rich String wrapper having all operations we know from the functional Vavr collections.Internal class, containing helpers.INTERNAL: CommonComparatorrelated functions (not intended to be public).Foldable<T>Interface of foldable data structures.HashArrayMappedTrie<K,V> An immutable Hash array mapped trie (HAMT).An abstract base class for nodes of a HAMT.Representation of a HAMT array node.The empty node.Representation of a HAMT indexed node.Representation of a HAMT leaf node with more than one element.Representation of a HAMT leaf.Representation of a HAMT leaf node with single element.HashMap<K,V> An immutableHashMapimplementation based on a Hash array mapped trie (HAMT).HashMultimap<K,V> HashSet<T>An immutableHashSetimplementation.A serialization proxy which, in this context, is used to deserialize immutable, linked Lists with final instance fields.IndexedSeq<T>Interface for immutable, indexed sequences.Iterator<T>io.vavr.collection.Iteratoris a compositional replacement forjava.util.Iteratorwhose purpose is to iterate once over a sequence of elements.THIS CLASS IS INTENDED TO BE USED INTERNALLY ONLY!JavaConverters.HasDelegate<C extends Traversable<?>>Encapsulates the access to delegate and performs mutability checks.JavaConverters.ListView<T, C extends Seq<T>>JavaConverters.ListView.Iterator<T, C extends Seq<T>>JavaConverters.ListView.ListIterator<T, C extends Seq<T>>LeafVisitor<T>LinearSeq<T>Interface for immutable, linear sequences.LinkedHashMap<K,V> An immutableLinkedHashMapimplementation that has predictable (insertion-order) iteration.LinkedHashMultimap<K,V> ALinkedHashMap-based implementation ofMultimapAn immutableHashSetimplementation that has predictable (insertion-order) iteration.A serialization proxy which, in this context, is used to deserialize immutable, linked Lists with final instance fields.List<T>An immutableListis an eager sequence of elements.List.Cons<T>Non-emptyList, consisting of aheadand atail.A serialization proxy which, in this context, is used to deserialize immutable, linked Lists with final instance fields.List.Nil<T>Representation of the singleton emptyList.Map<K,V> An immutableMapinterface.INTERNAL: CommonMapfunctions (not intended to be public).Multimap<K,V> An immutableMultimapinterface.INTERNAL: CommonMultimapfunctions (not intended to be public).Ordered<T>An ordered collection interface.A PriorityQueue.Queue<T>An immutableQueuestores elements allowing a first-in-first-out (FIFO) retrieval.RedBlackTree<T>Purely functional Red/Black Tree, inspired by Kazu Yamamoto's Haskell implementation.The empty tree node.A non-empty tree node.Seq<T>Interface for immutable sequential data structures.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.A serialization proxy which, in this context, is used to deserialize immutable, linked Streams with final instance fields.Traversable<T>An interface for inherently recursive, multi-valued data structures.Tree<T>A general Tree interface.Tree.Empty<T>The empty tree.Tree.Node<T>Represents a tree node.A serialization proxy which, in this context, is used to deserialize immutable nodes with final instance fields.Tree traversal order.TreeMap<K,V> SortedMap implementation, backed by a Red/Black Tree.Because the empty treeEmptycannot be a child of an existing tree, method implementations distinguish between the empty and non-empty case.TreeMultimap<K,V> 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.