@@ -13,7 +13,9 @@ import kotlinx.collections.immutable.implementations.immutableMap.PersistentHash
13
13
import kotlinx.collections.immutable.implementations.immutableSet.PersistentHashSet
14
14
import kotlinx.collections.immutable.implementations.immutableSet.PersistentHashSetBuilder
15
15
import kotlinx.collections.immutable.implementations.persistentOrderedMap.PersistentOrderedMap
16
+ import kotlinx.collections.immutable.implementations.persistentOrderedMap.PersistentOrderedMapBuilder
16
17
import kotlinx.collections.immutable.implementations.persistentOrderedSet.PersistentOrderedSet
18
+ import kotlinx.collections.immutable.implementations.persistentOrderedSet.PersistentOrderedSetBuilder
17
19
18
20
// @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
19
21
// inline fun <T> @kotlin.internal.Exact ImmutableCollection<T>.mutate(mutator: (MutableCollection<T>) -> Unit): ImmutableCollection<T> = builder().apply(mutator).build()
@@ -593,9 +595,9 @@ fun <T> Iterable<T>.toImmutableSet(): ImmutableSet<T> =
593
595
* Elements of the returned set are iterated in the same order as in this collection
594
596
*/
595
597
fun <T > Iterable<T>.toPersistentSet (): PersistentSet <T > =
596
- this as ? PersistentSet <T >
597
- ? : (this as ? PersistentSet . Builder )?.build()
598
- ? : persistentSetOf <T >() + this
598
+ this as ? PersistentOrderedSet <T >
599
+ ? : (this as ? PersistentOrderedSetBuilder )?.build()
600
+ ? : PersistentOrderedSet .emptyOf <T >() + this
599
601
600
602
/* *
601
603
* Returns a persistent set containing all elements from this set.
@@ -621,7 +623,7 @@ fun <T> Set<T>.toPersistentHashSet(): PersistentSet<T>
621
623
fun <K , V > Map <K , V >.toImmutableMap (): ImmutableMap <K , V >
622
624
= this as ? ImmutableMap
623
625
? : (this as ? PersistentMap .Builder )?.build()
624
- ? : PersistentOrderedMap .emptyOf <K , V >().putAll(this )
626
+ ? : persistentMapOf <K , V >().putAll(this )
625
627
626
628
/* *
627
629
* Returns a persistent map containing all entries from this map.
@@ -632,8 +634,8 @@ fun <K, V> Map<K, V>.toImmutableMap(): ImmutableMap<K, V>
632
634
* Entries of the returned map are iterated in the same order as in this map.
633
635
*/
634
636
fun <K , V > Map <K , V >.toPersistentMap (): PersistentMap <K , V >
635
- = this as ? PersistentMap <K , V >
636
- ? : (this as ? PersistentMap . Builder <K , V >)?.build()
637
+ = this as ? PersistentOrderedMap <K , V >
638
+ ? : (this as ? PersistentOrderedMapBuilder <K , V >)?.build()
637
639
? : PersistentOrderedMap .emptyOf<K , V >().putAll(this )
638
640
639
641
/* *
@@ -645,6 +647,6 @@ fun <K, V> Map<K, V>.toPersistentMap(): PersistentMap<K, V>
645
647
* Order of the entries in the returned map is unspecified.
646
648
*/
647
649
fun <K , V > Map <K , V >.toPersistentHashMap (): PersistentMap <K , V >
648
- = this as ? PersistentMap
650
+ = this as ? PersistentHashMap
649
651
? : (this as ? PersistentHashMapBuilder <K , V >)?.build()
650
652
? : PersistentHashMap .emptyOf<K , V >().putAll(this )
0 commit comments