Package io.vavr.collection


package io.vavr.collection
Purely functional collections based on Traversable.

Performance Characteristics of Vavr Collections

Time Complexity of Sequential Operations
  head() tail() get(int) update(int, T) prepend(T) append(T)
Arrayconstlinearconstlinearlinearlinear
CharSeqconstlinearconstlinearlinearlinear
Iteratorconstconst
Listconstconstlinearlinearconstlinear
Queueconstconstalinearlinearconstconst
PriorityQueueloglogloglog
Streamconstconstlinearlinearconstlazyconstlazy
Vectorconsteffconsteffconsteffconsteffconsteffconsteff

Time Complexity of Map/Set Operations
  contains/Key add/put remove min
HashMapconsteffconsteffconstefflinear
HashSetconsteffconsteffconstefflinear
LinkedHashMapconstefflinearlinearlinear
LinkedHashSetconstefflinearlinearlinear
Treeloglogloglog
TreeMaploglogloglog
TreeSetloglogloglog

  • 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
  • Class
    Description
    Array is an immutable Traversable wrapper for Object[] containing elements of type T.
    An immutable BitSet implementation.
    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 a char-valued argument and produces a result.
    Represents an operation on a single char-valued operand that produces a char-valued result.
    Represents a data structure that can be folded (reduced) into a single value.
    HashMap<K,V>
    An immutable HashMap implementation based on a Hash array mapped trie (HAMT).
    A HashMap-based implementation of Multimap
    Builder for creating HashMultimap instances with different container types.
    An immutable HashSet implementation.
    Represents an immutable, indexed sequence of elements.
    A compositional alternative to java.util.Iterator designed for single-pass traversal of a sequence.
    Interface for immutable, linear sequences.
    An immutable LinkedHashMap implementation that has predictable (insertion-order) iteration.
    A LinkedHashMap-based implementation of Multimap
    Builder class for creating LinkedHashMultimap instances.
    An immutable HashSet implementation that has predictable (insertion-order) iteration.
    List<T>
    An immutable List is an eager sequence of elements.
    Non-empty List, consisting of a head and a tail.
    Representation of the singleton empty List.
    Map<K,V>
    An immutable Map interface.
    An immutable Multimap interface.
    Defines the type of container used to store values associated with keys in a Multimap.
    A collection whose elements are arranged according to a well-defined order.
    A PriorityQueue.
    An immutable Queue stores elements allowing a first-in-first-out (FIFO) retrieval.
    Seq<T>
    Base interface for immutable, sequential collections.
    Set<T>
    An immutable Set interface.
    An immutable SortedMap interface.
    An immutable SortedMultimap interface.
    An immutable SortedSet interface.
    An immutable Stream is lazy sequence of elements which may be infinitely long.
    Non-empty Stream, consisting of a head, and tail.
    The empty Stream.
    Represents a recursive, multi-valued data structure whose elements can be traversed in order.
    Tree<T>
    A general Tree interface.
    The empty tree.
    Represents a tree node.
    Tree traversal order.
    TreeMap<K,V>
    An immutable SortedMap implementation backed by a Red-Black tree.
    A TreeMap-based implementation of Multimap
    Builder class for creating TreeMultimap instances.
    SortedSet implementation, backed by a Red/Black Tree.
    Vector is the default Seq implementation that provides effectively constant time access to any element.