Immutable persistent collections for Kotlin
toPersistentHashSet
to Iterable #77ConcurrentModificationException
if hashCode of ordered set element changes #76PersistentVector
to SmallPersistentVector
#75Update Kotlin version up to 1.3.70
kotlinx-collections-immutable
to kotlinx-collections-immutable-jvm
toPersistentMap
/Set
always returns an ordered persistent map/settoPersistentHashMap
/Set
always returns an unordered persistent map/settoImmutableMap
/Set
may return any kind of immutable map/setaddAll(elements)
operation performs ~3 times faster :chart_with_downwards_trend:addAll(index, elements)
operation takes O(N + M), down from O(N * M), where N is the size of this collection and M - the size of the elements
collection. :chart_with_downwards_trend:removeAll(elements)
operation takes O(N * K), down from O(N * M), where K is the time complexity of contains
operation on the elements
collection :chart_with_downwards_trend:removeAll(predicate)
operation takes O(N * P), down from O(N * (P + N)), where P is the time complexity of the predicate
algorithm :chart_with_downwards_trend:add
operation after remove
operations performs ~20% faster :chart_with_downwards_trend:remove
operations performs ~3 times faster :chart_with_downwards_trend:This release introduces two notable changes.
ImmutableCollection
extends read-only Collection
ImmutableList
extends read-only List
and ImmutableCollection
, and overrides subList
method that returns ImmutableList
ImmutableSet
extends read-only Set
and ImmutableCollection
ImmutableMap
extends read-only Map
, and overrides keys
, values
and entries
properties types with ImmutableSet
, ImmutableCollection
and ImmutableSet
respectivelyPersistentCollection
extends ImmutableCollection
, and provides modification operations and builderPersistentList
extends ImmutableList
and PersistentCollection
, and provides modification operationsPersistentSet
extends ImmutableSet
and PersistentCollection
, and provides modification operationsPersistentMap
extends ImmutableMap
, and provides modification operations and builderplus
, minus
and mutate
extension functions are available only for persistent collectionsimmutableXOf()
top-level functions and introduce persistentXOf()
toImmutableX()
extension functions return ImmutableX
toPersistentX()
extension functions that return PersistentX
PersistentList
implementation is backed by a bit-mapped trie with branching factor of 32
add(element: E)
and removeAt(size - 1)
operations take O(1) time, down from O(log2n) :chart_with_downwards_trend:get
and set
operations take O(log32n), down from O(log2n) (though the same asymptotic) :chart_with_downwards_trend:PersistentSet
implementation is backed by a hash-array mapped trie (a.k.a. HAMT) with up to 32 children or elements in a node
contains
, add
and remove
operations take O(log32n) time, down from O(log2n) :chart_with_downwards_trend:PersistentMap
implementation is backed by a compressed hash-array mapped prefix-tree (a.k.a. CHAMP) with up to 32 children or entries in a node
contains
, get
, put
and remove
operations take O(log32n) time, down from O(log2n) :chart_with_downwards_trend:PersistentSet
implementation is backed by the unordered PersistentMap
which maps elements in this set to next and previous elements in insertion order
contains
, get
and put
operations take O(log32n) time, down from O(log2n) :chart_with_downwards_trend:remove
operation takes O(log32n) time, down from O(n) :chart_with_downwards_trend:PersistentMap
implementation is backed by the unordered PersistentMap
which maps keys in this map to values, next and previous keys in insertion order
contains
, get
and put
operations take O(log32n) time, down from O(log2n) :chart_with_downwards_trend:remove
operation takes O(log32n) time, down from O(n) :chart_with_downwards_trend: