diff --git a/benchmarks/commonMain/src/benchmarks/immutableList/Add.kt b/benchmarks/commonMain/src/benchmarks/immutableList/Add.kt index d2f1ef32..c3afc525 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableList/Add.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableList/Add.kt @@ -46,7 +46,7 @@ open class Add { */ @Benchmark fun addFirst(): ImmutableList { - return persistentListAdd(size - 1).add(0, "another element") + return persistentListAdd(size - 1).adding(0, "another element") } /** @@ -60,6 +60,6 @@ open class Add { */ @Benchmark fun addMiddle(): ImmutableList { - return persistentListAdd(size - 1).add(size / 2, "another element") + return persistentListAdd(size - 1).adding(size / 2, "another element") } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableList/AddAll.kt b/benchmarks/commonMain/src/benchmarks/immutableList/AddAll.kt index b3688706..39b0ed2e 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableList/AddAll.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableList/AddAll.kt @@ -35,7 +35,7 @@ open class AddAll { */ @Benchmark fun addAllLast(): ImmutableList { - return persistentListOf().addAll(listToAdd) + return persistentListOf().addingAll(listToAdd) } /** @@ -46,7 +46,7 @@ open class AddAll { fun addAllLast_Half(): ImmutableList { val initialSize = size / 2 val subListToAdd = listToAdd.subList(0, size - initialSize) // assuming subList creation is neglectable - return persistentListAdd(initialSize).addAll(subListToAdd) + return persistentListAdd(initialSize).addingAll(subListToAdd) } /** @@ -57,7 +57,7 @@ open class AddAll { fun addAllLast_OneThird(): ImmutableList { val initialSize = size - size / 3 val subListToAdd = listToAdd.subList(0, size - initialSize) - return persistentListAdd(initialSize).addAll(subListToAdd) + return persistentListAdd(initialSize).addingAll(subListToAdd) } /** @@ -68,7 +68,7 @@ open class AddAll { fun addAllFirst_Half(): ImmutableList { val initialSize = size / 2 val subListToAdd = listToAdd.subList(0, size - initialSize) - return persistentListAdd(initialSize).addAll(0, subListToAdd) + return persistentListAdd(initialSize).addingAll(0, subListToAdd) } /** @@ -79,7 +79,7 @@ open class AddAll { fun addAllFirst_OneThird(): ImmutableList { val initialSize = size - size / 3 val subListToAdd = listToAdd.subList(0, size - initialSize) - return persistentListAdd(initialSize).addAll(0, subListToAdd) + return persistentListAdd(initialSize).addingAll(0, subListToAdd) } /** @@ -91,7 +91,7 @@ open class AddAll { val initialSize = size / 2 val index = initialSize / 2 val subListToAdd = listToAdd.subList(0, size - initialSize) - return persistentListAdd(initialSize).addAll(index, subListToAdd) + return persistentListAdd(initialSize).addingAll(index, subListToAdd) } /** @@ -103,6 +103,6 @@ open class AddAll { val initialSize = size - size / 3 val index = initialSize / 2 val subListToAdd = listToAdd.subList(0, size - initialSize) - return persistentListAdd(initialSize).addAll(index, subListToAdd) + return persistentListAdd(initialSize).addingAll(index, subListToAdd) } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableList/Remove.kt b/benchmarks/commonMain/src/benchmarks/immutableList/Remove.kt index 6e1e3c07..ac3c322f 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableList/Remove.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableList/Remove.kt @@ -27,7 +27,7 @@ open class Remove { fun removeLast(): ImmutableList { var list = persistentList repeat(times = size) { - list = list.removeAt(list.size - 1) + list = list.removingAt(list.size - 1) } return list } @@ -43,7 +43,7 @@ open class Remove { @Benchmark fun removeFirst(): ImmutableList { val list = persistentList - return list.removeAt(0) + return list.removingAt(0) } /** @@ -57,6 +57,6 @@ open class Remove { @Benchmark fun removeMiddle(): ImmutableList { val list = persistentList - return list.removeAt(size / 2) + return list.removingAt(size / 2) } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableList/RemoveAll.kt b/benchmarks/commonMain/src/benchmarks/immutableList/RemoveAll.kt index 9edff485..42567435 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableList/RemoveAll.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableList/RemoveAll.kt @@ -20,7 +20,7 @@ open class RemoveAll { @Setup fun prepare() { - persistentList = persistentListOf().addAll(List(size) { it }) + persistentList = persistentListOf().addingAll(List(size) { it }) } // Results of the following benchmarks do not indicate memory or time spent per operation, @@ -38,7 +38,7 @@ open class RemoveAll { fun removeAll_All(): PersistentList { val list = persistentList val elementsToRemove = List(size) { it } - return list.removeAll(elementsToRemove) + return list.removingAll(elementsToRemove) } /** @@ -48,7 +48,7 @@ open class RemoveAll { fun removeAll_RandomHalf(): PersistentList { val list = persistentList val elementsToRemove = randomIndexes(size / 2) - return list.removeAll(elementsToRemove) + return list.removingAll(elementsToRemove) } /** @@ -58,7 +58,7 @@ open class RemoveAll { fun removeAll_RandomTen(): PersistentList { val list = persistentList val elementsToRemove = randomIndexes(10) - return list.removeAll(elementsToRemove) + return list.removingAll(elementsToRemove) } /** @@ -68,7 +68,7 @@ open class RemoveAll { fun removeAll_Tail(): PersistentList { val list = persistentList val elementsToRemove = List(tailSize()) { size - 1 - it } - return list.removeAll(elementsToRemove) + return list.removingAll(elementsToRemove) } /** @@ -78,7 +78,7 @@ open class RemoveAll { fun removeAll_NonExisting(): PersistentList { val list = persistentList val elementsToRemove = randomIndexes(10).map { size + it } - return list.removeAll(elementsToRemove) + return list.removingAll(elementsToRemove) } private fun randomIndexes(count: Int): List { @@ -89,4 +89,4 @@ open class RemoveAll { val bufferSize = 32 return (size and (bufferSize - 1)).let { if (it == 0) bufferSize else it } } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableList/RemoveAllPredicate.kt b/benchmarks/commonMain/src/benchmarks/immutableList/RemoveAllPredicate.kt index 46f3aae2..a1100a8e 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableList/RemoveAllPredicate.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableList/RemoveAllPredicate.kt @@ -39,7 +39,7 @@ open class RemoveAllPredicate { tailElementsPredicate = { it in tailElements } val allElements = List(size) { it.toString() } - persistentList = persistentListOf().addAll(allElements) + persistentList = persistentListOf().addingAll(allElements) } // The benchmarks measure (time and memory spent in `removeAll` operation) / size @@ -50,37 +50,37 @@ open class RemoveAllPredicate { /** Removes all elements. */ @Benchmark fun removeAll_All(): PersistentList { - return persistentList.removeAll(truePredicate) + return persistentList.removingAll(truePredicate) } /** Removes no elements. */ @Benchmark fun removeAll_Non(): PersistentList { - return persistentList.removeAll(falsePredicate) + return persistentList.removingAll(falsePredicate) } /** Removes half of the elements randomly selected. */ @Benchmark fun removeAll_RandomHalf(): PersistentList { - return persistentList.removeAll(randomHalfElementsPredicate) + return persistentList.removingAll(randomHalfElementsPredicate) } /** Removes 10 random elements. */ @Benchmark fun removeAll_RandomTen(): PersistentList { - return persistentList.removeAll(randomTenElementsPredicate) + return persistentList.removingAll(randomTenElementsPredicate) } /** Removes a random element. */ @Benchmark fun removeAll_RandomOne(): PersistentList { - return persistentList.removeAll(randomOneElementPredicate) + return persistentList.removingAll(randomOneElementPredicate) } /** Removes last [tailSize] elements. */ @Benchmark fun removeAll_Tail(): PersistentList { - return persistentList.removeAll(tailElementsPredicate) + return persistentList.removingAll(tailElementsPredicate) } private fun randomIndexes(count: Int): List { diff --git a/benchmarks/commonMain/src/benchmarks/immutableList/Set.kt b/benchmarks/commonMain/src/benchmarks/immutableList/Set.kt index e7282aff..cb66a15a 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableList/Set.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableList/Set.kt @@ -28,7 +28,7 @@ open class Set { @Benchmark fun setByIndex(): ImmutableList { repeat(times = size) { index -> - persistentList = persistentList.set(index, "another element") + persistentList = persistentList.replacingAt(index, "another element") } return persistentList } @@ -36,8 +36,8 @@ open class Set { @Benchmark fun setByRandomIndex(): ImmutableList { repeat(times = size) { index -> - persistentList = persistentList.set(randomIndices[index], "another element") + persistentList = persistentList.replacingAt(randomIndices[index], "another element") } return persistentList } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableList/builder/RemoveAll.kt b/benchmarks/commonMain/src/benchmarks/immutableList/builder/RemoveAll.kt index f2c994f3..5b09c5de 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableList/builder/RemoveAll.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableList/builder/RemoveAll.kt @@ -86,7 +86,7 @@ open class RemoveAll { val immutableSize = immutableSize(size, immutablePercentage) var list = persistentListOf() for (i in 0 until immutableSize) { - list = list.add(i) + list = list.adding(i) } val builder = list.builder() for (i in immutableSize until size) { @@ -103,4 +103,4 @@ open class RemoveAll { val bufferSize = 32 return (size and (bufferSize - 1)).let { if (it == 0) bufferSize else it } } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableList/utils.kt b/benchmarks/commonMain/src/benchmarks/immutableList/utils.kt index e2865b49..ed1b3879 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableList/utils.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableList/utils.kt @@ -11,7 +11,7 @@ import kotlinx.collections.immutable.persistentListOf fun persistentListAdd(size: Int): PersistentList { var list = persistentListOf() repeat(times = size) { - list = list.add("some element") + list = list.adding("some element") } return list -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableMap/Canonicalization.kt b/benchmarks/commonMain/src/benchmarks/immutableMap/Canonicalization.kt index ad7c2338..2647a202 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableMap/Canonicalization.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableMap/Canonicalization.kt @@ -68,7 +68,7 @@ open class Canonicalization { var map = persistentMapRemove(persistentMap, keysToRemove) for (key in keysToRemove) { - map = map.put(key, "new value") + map = map.putting(key, "new value") } return map @@ -111,7 +111,7 @@ open class Canonicalization { var map = halfHeightPersistentMap repeat(size - halfHeightPersistentMap.size) { index -> - map = map.put(keys[index], "new value") + map = map.putting(keys[index], "new value") } return map @@ -137,4 +137,4 @@ open class Canonicalization { } } } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableMap/Equals.kt b/benchmarks/commonMain/src/benchmarks/immutableMap/Equals.kt index 1c3dc746..735dadb8 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableMap/Equals.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableMap/Equals.kt @@ -30,7 +30,7 @@ open class Equals { val keys = generateKeys(hashCodeType, size * 2) persistentMap = persistentMapPut(implementation, keys.take(size)) sameMap = persistentMapPut(implementation, keys.take(size)) - slightlyDifferentMap = sameMap.put(keys[size], "different value").remove(keys[0]) + slightlyDifferentMap = sameMap.putting(keys[size], "different value").removing(keys[0]) veryDifferentMap = persistentMapPut(implementation, keys.drop(size)) } @@ -40,4 +40,4 @@ open class Equals { fun nearlyEquals() = persistentMap == slightlyDifferentMap @Benchmark fun notEquals() = persistentMap == veryDifferentMap -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableMap/PutAll.kt b/benchmarks/commonMain/src/benchmarks/immutableMap/PutAll.kt index be432bef..b020a880 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableMap/PutAll.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableMap/PutAll.kt @@ -37,16 +37,16 @@ open class PutAll { @Benchmark fun putAllEqualSize(): PersistentMap { - return lhs.putAll(rhs) + return lhs.puttingAll(rhs) } @Benchmark fun putAllSmallIntoLarge(): PersistentMap { - return lhs.putAll(rhsSmall) + return lhs.puttingAll(rhsSmall) } @Benchmark fun putAllLargeIntoSmall(): PersistentMap { - return lhsSmall.putAll(rhs) + return lhsSmall.puttingAll(rhs) } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableMap/Remove.kt b/benchmarks/commonMain/src/benchmarks/immutableMap/Remove.kt index 345c0d2b..4496a82c 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableMap/Remove.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableMap/Remove.kt @@ -37,8 +37,8 @@ open class Remove { fun remove(): PersistentMap { var map = persistentMap repeat(times = size) { index -> - map = map.remove(keys[index]) + map = map.removing(keys[index]) } return map } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableMap/builder/utils.kt b/benchmarks/commonMain/src/benchmarks/immutableMap/builder/utils.kt index 4631b2c8..acd22484 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableMap/builder/utils.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableMap/builder/utils.kt @@ -19,7 +19,7 @@ fun persistentMapBuilderPut( var map = emptyPersistentMap(implementation) for (index in 0 until immutableSize) { - map = map.put(keys[index], "some value") + map = map.putting(keys[index], "some value") } val builder = map.builder() diff --git a/benchmarks/commonMain/src/benchmarks/immutableMap/utils.kt b/benchmarks/commonMain/src/benchmarks/immutableMap/utils.kt index d2f9f08e..aaa35e24 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableMap/utils.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableMap/utils.kt @@ -22,7 +22,7 @@ fun emptyPersistentMap(implementation: String): PersistentMap = whe fun persistentMapPut(implementation: String, keys: List): PersistentMap { var map = emptyPersistentMap(implementation) for (key in keys) { - map = map.put(key, "some value") + map = map.putting(key, "some value") } return map } @@ -30,7 +30,7 @@ fun persistentMapPut(implementation: String, keys: List): PersistentMap persistentMapRemove(persistentMap: PersistentMap, keys: List): PersistentMap { var map = persistentMap for (key in keys) { - map = map.remove(key) + map = map.removing(key) } return map } diff --git a/benchmarks/commonMain/src/benchmarks/immutableSet/Canonicalization.kt b/benchmarks/commonMain/src/benchmarks/immutableSet/Canonicalization.kt index e2099c68..7971e6d1 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableSet/Canonicalization.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableSet/Canonicalization.kt @@ -68,7 +68,7 @@ open class Canonicalization { var set = persistentSetRemove(persistentSet, elementsToRemove) for (element in elementsToRemove) { - set = set.add(element) + set = set.adding(element) } return set @@ -111,7 +111,7 @@ open class Canonicalization { var set = halfHeightPersistentSet for (element in elementsToRemove) { - set = set.add(element) + set = set.adding(element) } return set @@ -137,4 +137,4 @@ open class Canonicalization { } } } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableSet/Equals.kt b/benchmarks/commonMain/src/benchmarks/immutableSet/Equals.kt index 78db8603..b1720a86 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableSet/Equals.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableSet/Equals.kt @@ -30,7 +30,7 @@ open class Equals { val keys = generateKeys(hashCodeType, size * 2) persistentSet = persistentSetAdd(implementation, keys.take(size)) sameSet = persistentSetAdd(implementation, keys.take(size)) - slightlyDifferentSet = sameSet.add(keys[size]).remove(keys[0]) + slightlyDifferentSet = sameSet.adding(keys[size]).removing(keys[0]) veryDifferentSet = persistentSetAdd(implementation, keys.drop(size)) } @@ -40,4 +40,4 @@ open class Equals { fun nearlyEquals() = persistentSet == slightlyDifferentSet @Benchmark fun notEquals() = persistentSet == veryDifferentSet -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableSet/Remove.kt b/benchmarks/commonMain/src/benchmarks/immutableSet/Remove.kt index c2263f7a..a4871a4b 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableSet/Remove.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableSet/Remove.kt @@ -37,8 +37,8 @@ open class Remove { fun remove(): ImmutableSet { var set = persistentSet repeat(times = size) { index -> - set = set.remove(elements[index]) + set = set.removing(elements[index]) } return set } -} \ No newline at end of file +} diff --git a/benchmarks/commonMain/src/benchmarks/immutableSet/builder/utils.kt b/benchmarks/commonMain/src/benchmarks/immutableSet/builder/utils.kt index a994b3f7..3548a23b 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableSet/builder/utils.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableSet/builder/utils.kt @@ -18,7 +18,7 @@ fun persistentSetBuilderAdd( var set = emptyPersistentSet(implementation) for (index in 0 until immutableSize) { - set = set.add(elements[index]) + set = set.adding(elements[index]) } val builder = set.builder() diff --git a/benchmarks/commonMain/src/benchmarks/immutableSet/utils.kt b/benchmarks/commonMain/src/benchmarks/immutableSet/utils.kt index cc06827d..96d6566e 100644 --- a/benchmarks/commonMain/src/benchmarks/immutableSet/utils.kt +++ b/benchmarks/commonMain/src/benchmarks/immutableSet/utils.kt @@ -22,7 +22,7 @@ fun emptyPersistentSet(implementation: String): PersistentSet = when (imp fun persistentSetAdd(implementation: String, elements: List): PersistentSet { var set = emptyPersistentSet(implementation) for (element in elements) { - set = set.add(element) + set = set.adding(element) } return set } @@ -30,7 +30,7 @@ fun persistentSetAdd(implementation: String, elements: List): PersistentS fun persistentSetRemove(persistentSet: PersistentSet, elements: List): PersistentSet { var set = persistentSet for (element in elements) { - set = set.remove(element) + set = set.removing(element) } return set } diff --git a/core/api/kotlinx-collections-immutable.api b/core/api/kotlinx-collections-immutable.api index 09231a36..6ee270f8 100644 --- a/core/api/kotlinx-collections-immutable.api +++ b/core/api/kotlinx-collections-immutable.api @@ -58,6 +58,10 @@ public final class kotlinx/collections/immutable/ExtensionsKt { public static final fun putAll (Lkotlinx/collections/immutable/PersistentMap;Ljava/util/Map;)Lkotlinx/collections/immutable/PersistentMap; public static final fun putAll (Lkotlinx/collections/immutable/PersistentMap;Lkotlin/sequences/Sequence;)Lkotlinx/collections/immutable/PersistentMap; public static final fun putAll (Lkotlinx/collections/immutable/PersistentMap;[Lkotlin/Pair;)Lkotlinx/collections/immutable/PersistentMap; + public static final fun puttingAll (Lkotlinx/collections/immutable/PersistentMap;Ljava/lang/Iterable;)Lkotlinx/collections/immutable/PersistentMap; + public static final fun puttingAll (Lkotlinx/collections/immutable/PersistentMap;Ljava/util/Map;)Lkotlinx/collections/immutable/PersistentMap; + public static final fun puttingAll (Lkotlinx/collections/immutable/PersistentMap;Lkotlin/sequences/Sequence;)Lkotlinx/collections/immutable/PersistentMap; + public static final fun puttingAll (Lkotlinx/collections/immutable/PersistentMap;[Lkotlin/Pair;)Lkotlinx/collections/immutable/PersistentMap; public static final fun toImmutableList (Ljava/lang/CharSequence;)Lkotlinx/collections/immutable/ImmutableList; public static final fun toImmutableList (Ljava/lang/Iterable;)Lkotlinx/collections/immutable/ImmutableList; public static final fun toImmutableList (Lkotlin/sequences/Sequence;)Lkotlinx/collections/immutable/ImmutableList; @@ -106,12 +110,19 @@ public abstract interface class kotlinx/collections/immutable/ImmutableSet : jav public abstract interface class kotlinx/collections/immutable/PersistentCollection : kotlinx/collections/immutable/ImmutableCollection { public abstract fun add (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentCollection; public abstract fun addAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; + public abstract fun adding (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentCollection; + public abstract fun addingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; public abstract fun builder ()Lkotlinx/collections/immutable/PersistentCollection$Builder; public abstract fun clear ()Lkotlinx/collections/immutable/PersistentCollection; + public abstract fun cleared ()Lkotlinx/collections/immutable/PersistentCollection; public abstract fun remove (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentCollection; public abstract fun removeAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; public abstract fun removeAll (Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentCollection; + public abstract fun removing (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentCollection; + public abstract fun removingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; + public abstract fun removingAll (Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentCollection; public abstract fun retainAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; + public abstract fun retainingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; } public abstract interface class kotlinx/collections/immutable/PersistentCollection$Builder : java/util/Collection, kotlin/jvm/internal/markers/KMutableCollection { @@ -123,13 +134,24 @@ public abstract interface class kotlinx/collections/immutable/PersistentList : k public abstract fun add (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; public abstract fun addAll (ILjava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; public abstract fun addAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public abstract fun adding (ILjava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; + public abstract fun adding (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; + public abstract fun addingAll (ILjava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public abstract fun addingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; public abstract fun builder ()Lkotlinx/collections/immutable/PersistentList$Builder; public abstract fun clear ()Lkotlinx/collections/immutable/PersistentList; + public abstract fun cleared ()Lkotlinx/collections/immutable/PersistentList; public abstract fun remove (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; public abstract fun removeAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; public abstract fun removeAll (Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentList; public abstract fun removeAt (I)Lkotlinx/collections/immutable/PersistentList; + public abstract fun removing (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; + public abstract fun removingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public abstract fun removingAll (Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentList; + public abstract fun removingAt (I)Lkotlinx/collections/immutable/PersistentList; + public abstract fun replacingAt (ILjava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; public abstract fun retainAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public abstract fun retainingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; public abstract fun set (ILjava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; } @@ -138,37 +160,78 @@ public abstract interface class kotlinx/collections/immutable/PersistentList$Bui } public final class kotlinx/collections/immutable/PersistentList$DefaultImpls { + public static fun add (Lkotlinx/collections/immutable/PersistentList;ILjava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; + public static fun add (Lkotlinx/collections/immutable/PersistentList;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; + public static fun addAll (Lkotlinx/collections/immutable/PersistentList;ILjava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public static fun addAll (Lkotlinx/collections/immutable/PersistentList;Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public static fun clear (Lkotlinx/collections/immutable/PersistentList;)Lkotlinx/collections/immutable/PersistentList; + public static fun remove (Lkotlinx/collections/immutable/PersistentList;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; + public static fun removeAll (Lkotlinx/collections/immutable/PersistentList;Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public static fun removeAll (Lkotlinx/collections/immutable/PersistentList;Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentList; + public static fun removeAt (Lkotlinx/collections/immutable/PersistentList;I)Lkotlinx/collections/immutable/PersistentList; + public static fun retainAll (Lkotlinx/collections/immutable/PersistentList;Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public static fun set (Lkotlinx/collections/immutable/PersistentList;ILjava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; public static fun subList (Lkotlinx/collections/immutable/PersistentList;II)Lkotlinx/collections/immutable/ImmutableList; } public abstract interface class kotlinx/collections/immutable/PersistentMap : kotlinx/collections/immutable/ImmutableMap { public abstract fun builder ()Lkotlinx/collections/immutable/PersistentMap$Builder; public abstract fun clear ()Lkotlinx/collections/immutable/PersistentMap; + public abstract fun cleared ()Lkotlinx/collections/immutable/PersistentMap; public abstract fun put (Ljava/lang/Object;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; public abstract fun putAll (Ljava/util/Map;)Lkotlinx/collections/immutable/PersistentMap; + public abstract fun putting (Ljava/lang/Object;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; + public abstract fun puttingAll (Ljava/util/Map;)Lkotlinx/collections/immutable/PersistentMap; public abstract fun remove (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; public abstract fun remove (Ljava/lang/Object;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; + public abstract fun removing (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; + public abstract fun removing (Ljava/lang/Object;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; } public abstract interface class kotlinx/collections/immutable/PersistentMap$Builder : java/util/Map, kotlin/jvm/internal/markers/KMutableMap { public abstract fun build ()Lkotlinx/collections/immutable/PersistentMap; } +public final class kotlinx/collections/immutable/PersistentMap$DefaultImpls { + public static fun clear (Lkotlinx/collections/immutable/PersistentMap;)Lkotlinx/collections/immutable/PersistentMap; + public static fun put (Lkotlinx/collections/immutable/PersistentMap;Ljava/lang/Object;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; + public static fun putAll (Lkotlinx/collections/immutable/PersistentMap;Ljava/util/Map;)Lkotlinx/collections/immutable/PersistentMap; + public static fun remove (Lkotlinx/collections/immutable/PersistentMap;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; + public static fun remove (Lkotlinx/collections/immutable/PersistentMap;Ljava/lang/Object;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentMap; +} + public abstract interface class kotlinx/collections/immutable/PersistentSet : kotlinx/collections/immutable/ImmutableSet, kotlinx/collections/immutable/PersistentCollection { public abstract fun add (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentSet; public abstract fun addAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; + public abstract fun adding (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentSet; + public abstract fun addingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; public abstract fun builder ()Lkotlinx/collections/immutable/PersistentSet$Builder; public abstract fun clear ()Lkotlinx/collections/immutable/PersistentSet; + public abstract fun cleared ()Lkotlinx/collections/immutable/PersistentSet; public abstract fun remove (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentSet; public abstract fun removeAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; public abstract fun removeAll (Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentSet; + public abstract fun removing (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentSet; + public abstract fun removingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; + public abstract fun removingAll (Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentSet; public abstract fun retainAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; + public abstract fun retainingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; } public abstract interface class kotlinx/collections/immutable/PersistentSet$Builder : java/util/Set, kotlin/jvm/internal/markers/KMutableSet, kotlinx/collections/immutable/PersistentCollection$Builder { public abstract fun build ()Lkotlinx/collections/immutable/PersistentSet; } +public final class kotlinx/collections/immutable/PersistentSet$DefaultImpls { + public static fun add (Lkotlinx/collections/immutable/PersistentSet;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentSet; + public static fun addAll (Lkotlinx/collections/immutable/PersistentSet;Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; + public static fun clear (Lkotlinx/collections/immutable/PersistentSet;)Lkotlinx/collections/immutable/PersistentSet; + public static fun remove (Lkotlinx/collections/immutable/PersistentSet;Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentSet; + public static fun removeAll (Lkotlinx/collections/immutable/PersistentSet;Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; + public static fun removeAll (Lkotlinx/collections/immutable/PersistentSet;Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentSet; + public static fun retainAll (Lkotlinx/collections/immutable/PersistentSet;Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentSet; +} + public class kotlinx/collections/immutable/adapters/ImmutableCollectionAdapter : java/util/Collection, kotlin/jvm/internal/markers/KMappedMarker, kotlinx/collections/immutable/ImmutableCollection { public fun (Ljava/util/Collection;)V public fun add (Ljava/lang/Object;)Z @@ -197,6 +260,8 @@ public final class kotlinx/collections/immutable/adapters/ImmutableListAdapter : public fun add (Ljava/lang/Object;)Z public fun addAll (ILjava/util/Collection;)Z public fun addAll (Ljava/util/Collection;)Z + public fun addFirst (Ljava/lang/Object;)V + public fun addLast (Ljava/lang/Object;)V public fun clear ()V public fun contains (Ljava/lang/Object;)Z public fun containsAll (Ljava/util/Collection;)Z @@ -213,6 +278,8 @@ public final class kotlinx/collections/immutable/adapters/ImmutableListAdapter : public fun remove (I)Ljava/lang/Object; public fun remove (Ljava/lang/Object;)Z public fun removeAll (Ljava/util/Collection;)Z + public fun removeFirst ()Ljava/lang/Object; + public fun removeLast ()Ljava/lang/Object; public fun replaceAll (Ljava/util/function/UnaryOperator;)V public fun retainAll (Ljava/util/Collection;)Z public fun set (ILjava/lang/Object;)Ljava/lang/Object; @@ -266,11 +333,19 @@ public final class kotlinx/collections/immutable/adapters/ImmutableSetAdapter : public abstract class kotlinx/collections/immutable/implementations/immutableList/AbstractPersistentList : kotlin/collections/AbstractList, kotlinx/collections/immutable/PersistentList { public fun ()V + public fun add (ILjava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; + public synthetic fun add (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentCollection; + public fun add (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; public fun addAll (ILjava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; public synthetic fun addAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; public fun addAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public fun addingAll (ILjava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public synthetic fun addingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; + public fun addingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; public synthetic fun clear ()Lkotlinx/collections/immutable/PersistentCollection; public fun clear ()Lkotlinx/collections/immutable/PersistentList; + public synthetic fun cleared ()Lkotlinx/collections/immutable/PersistentCollection; + public fun cleared ()Lkotlinx/collections/immutable/PersistentList; public fun contains (Ljava/lang/Object;)Z public fun containsAll (Ljava/util/Collection;)Z public fun iterator ()Ljava/util/Iterator; @@ -279,8 +354,18 @@ public abstract class kotlinx/collections/immutable/implementations/immutableLis public fun remove (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; public synthetic fun removeAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; public fun removeAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public synthetic fun removeAll (Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentCollection; + public fun removeAll (Lkotlin/jvm/functions/Function1;)Lkotlinx/collections/immutable/PersistentList; + public fun removeAt (I)Lkotlinx/collections/immutable/PersistentList; + public synthetic fun removing (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentCollection; + public fun removing (Ljava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; + public synthetic fun removingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; + public fun removingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; public synthetic fun retainAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; public fun retainAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public synthetic fun retainingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentCollection; + public fun retainingAll (Ljava/util/Collection;)Lkotlinx/collections/immutable/PersistentList; + public fun set (ILjava/lang/Object;)Lkotlinx/collections/immutable/PersistentList; public synthetic fun subList (II)Ljava/util/List; public fun subList (II)Lkotlinx/collections/immutable/ImmutableList; } diff --git a/core/api/kotlinx-collections-immutable.klib.api b/core/api/kotlinx-collections-immutable.klib.api index 4bd7b493..4f1def7e 100644 --- a/core/api/kotlinx-collections-immutable.klib.api +++ b/core/api/kotlinx-collections-immutable.klib.api @@ -17,11 +17,16 @@ abstract interface <#A: kotlin/Any?, #B: out kotlin/Any?> kotlinx.collections.im abstract interface <#A: kotlin/Any?, #B: out kotlin/Any?> kotlinx.collections.immutable/PersistentMap : kotlinx.collections.immutable/ImmutableMap<#A, #B> { // kotlinx.collections.immutable/PersistentMap|null[0] abstract fun builder(): kotlinx.collections.immutable/PersistentMap.Builder<#A, #B> // kotlinx.collections.immutable/PersistentMap.builder|builder(){}[0] - abstract fun clear(): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.clear|clear(){}[0] - abstract fun put(#A, #B): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.put|put(1:0;1:1){}[0] - abstract fun putAll(kotlin.collections/Map): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.putAll|putAll(kotlin.collections.Map){}[0] - abstract fun remove(#A): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.remove|remove(1:0){}[0] - abstract fun remove(#A, #B): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.remove|remove(1:0;1:1){}[0] + abstract fun cleared(): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.cleared|cleared(){}[0] + abstract fun putting(#A, #B): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.putting|putting(1:0;1:1){}[0] + abstract fun puttingAll(kotlin.collections/Map): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.puttingAll|puttingAll(kotlin.collections.Map){}[0] + abstract fun removing(#A): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.removing|removing(1:0){}[0] + abstract fun removing(#A, #B): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.removing|removing(1:0;1:1){}[0] + open fun clear(): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.clear|clear(){}[0] + open fun put(#A, #B): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.put|put(1:0;1:1){}[0] + open fun putAll(kotlin.collections/Map): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.putAll|putAll(kotlin.collections.Map){}[0] + open fun remove(#A): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.remove|remove(1:0){}[0] + open fun remove(#A, #B): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/PersistentMap.remove|remove(1:0;1:1){}[0] abstract interface <#A1: kotlin/Any?, #B1: kotlin/Any?> Builder : kotlin.collections/MutableMap<#A1, #B1> { // kotlinx.collections.immutable/PersistentMap.Builder|null[0] abstract fun build(): kotlinx.collections.immutable/PersistentMap<#A1, #B1> // kotlinx.collections.immutable/PersistentMap.Builder.build|build(){}[0] @@ -39,12 +44,19 @@ abstract interface <#A: out kotlin/Any?> kotlinx.collections.immutable/Immutable abstract interface <#A: out kotlin/Any?> kotlinx.collections.immutable/PersistentCollection : kotlinx.collections.immutable/ImmutableCollection<#A> { // kotlinx.collections.immutable/PersistentCollection|null[0] abstract fun add(#A): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.add|add(1:0){}[0] abstract fun addAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.addAll|addAll(kotlin.collections.Collection<1:0>){}[0] + abstract fun adding(#A): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.adding|adding(1:0){}[0] + abstract fun addingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.addingAll|addingAll(kotlin.collections.Collection<1:0>){}[0] abstract fun builder(): kotlinx.collections.immutable/PersistentCollection.Builder<#A> // kotlinx.collections.immutable/PersistentCollection.builder|builder(){}[0] abstract fun clear(): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.clear|clear(){}[0] + abstract fun cleared(): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.cleared|cleared(){}[0] abstract fun remove(#A): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.remove|remove(1:0){}[0] abstract fun removeAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.removeAll|removeAll(kotlin.collections.Collection<1:0>){}[0] abstract fun removeAll(kotlin/Function1<#A, kotlin/Boolean>): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.removeAll|removeAll(kotlin.Function1<1:0,kotlin.Boolean>){}[0] + abstract fun removing(#A): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.removing|removing(1:0){}[0] + abstract fun removingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.removingAll|removingAll(kotlin.collections.Collection<1:0>){}[0] + abstract fun removingAll(kotlin/Function1<#A, kotlin/Boolean>): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.removingAll|removingAll(kotlin.Function1<1:0,kotlin.Boolean>){}[0] abstract fun retainAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.retainAll|retainAll(kotlin.collections.Collection<1:0>){}[0] + abstract fun retainingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentCollection<#A> // kotlinx.collections.immutable/PersistentCollection.retainingAll|retainingAll(kotlin.collections.Collection<1:0>){}[0] abstract interface <#A1: kotlin/Any?> Builder : kotlin.collections/MutableCollection<#A1> { // kotlinx.collections.immutable/PersistentCollection.Builder|null[0] abstract fun build(): kotlinx.collections.immutable/PersistentCollection<#A1> // kotlinx.collections.immutable/PersistentCollection.Builder.build|build(){}[0] @@ -52,18 +64,29 @@ abstract interface <#A: out kotlin/Any?> kotlinx.collections.immutable/Persisten } abstract interface <#A: out kotlin/Any?> kotlinx.collections.immutable/PersistentList : kotlinx.collections.immutable/ImmutableList<#A>, kotlinx.collections.immutable/PersistentCollection<#A> { // kotlinx.collections.immutable/PersistentList|null[0] - abstract fun add(#A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.add|add(1:0){}[0] - abstract fun add(kotlin/Int, #A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.add|add(kotlin.Int;1:0){}[0] - abstract fun addAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.addAll|addAll(kotlin.collections.Collection<1:0>){}[0] - abstract fun addAll(kotlin/Int, kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.addAll|addAll(kotlin.Int;kotlin.collections.Collection<1:0>){}[0] + abstract fun adding(#A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.adding|adding(1:0){}[0] + abstract fun adding(kotlin/Int, #A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.adding|adding(kotlin.Int;1:0){}[0] + abstract fun addingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.addingAll|addingAll(kotlin.collections.Collection<1:0>){}[0] + abstract fun addingAll(kotlin/Int, kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.addingAll|addingAll(kotlin.Int;kotlin.collections.Collection<1:0>){}[0] abstract fun builder(): kotlinx.collections.immutable/PersistentList.Builder<#A> // kotlinx.collections.immutable/PersistentList.builder|builder(){}[0] - abstract fun clear(): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.clear|clear(){}[0] - abstract fun remove(#A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.remove|remove(1:0){}[0] - abstract fun removeAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removeAll|removeAll(kotlin.collections.Collection<1:0>){}[0] - abstract fun removeAll(kotlin/Function1<#A, kotlin/Boolean>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removeAll|removeAll(kotlin.Function1<1:0,kotlin.Boolean>){}[0] - abstract fun removeAt(kotlin/Int): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removeAt|removeAt(kotlin.Int){}[0] - abstract fun retainAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.retainAll|retainAll(kotlin.collections.Collection<1:0>){}[0] - abstract fun set(kotlin/Int, #A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.set|set(kotlin.Int;1:0){}[0] + abstract fun cleared(): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.cleared|cleared(){}[0] + abstract fun removing(#A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removing|removing(1:0){}[0] + abstract fun removingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removingAll|removingAll(kotlin.collections.Collection<1:0>){}[0] + abstract fun removingAll(kotlin/Function1<#A, kotlin/Boolean>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removingAll|removingAll(kotlin.Function1<1:0,kotlin.Boolean>){}[0] + abstract fun removingAt(kotlin/Int): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removingAt|removingAt(kotlin.Int){}[0] + abstract fun replacingAt(kotlin/Int, #A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.replacingAt|replacingAt(kotlin.Int;1:0){}[0] + abstract fun retainingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.retainingAll|retainingAll(kotlin.collections.Collection<1:0>){}[0] + open fun add(#A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.add|add(1:0){}[0] + open fun add(kotlin/Int, #A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.add|add(kotlin.Int;1:0){}[0] + open fun addAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.addAll|addAll(kotlin.collections.Collection<1:0>){}[0] + open fun addAll(kotlin/Int, kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.addAll|addAll(kotlin.Int;kotlin.collections.Collection<1:0>){}[0] + open fun clear(): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.clear|clear(){}[0] + open fun remove(#A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.remove|remove(1:0){}[0] + open fun removeAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removeAll|removeAll(kotlin.collections.Collection<1:0>){}[0] + open fun removeAll(kotlin/Function1<#A, kotlin/Boolean>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removeAll|removeAll(kotlin.Function1<1:0,kotlin.Boolean>){}[0] + open fun removeAt(kotlin/Int): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.removeAt|removeAt(kotlin.Int){}[0] + open fun retainAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.retainAll|retainAll(kotlin.collections.Collection<1:0>){}[0] + open fun set(kotlin/Int, #A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable/PersistentList.set|set(kotlin.Int;1:0){}[0] abstract interface <#A1: kotlin/Any?> Builder : kotlin.collections/MutableList<#A1>, kotlinx.collections.immutable/PersistentCollection.Builder<#A1> { // kotlinx.collections.immutable/PersistentList.Builder|null[0] abstract fun build(): kotlinx.collections.immutable/PersistentList<#A1> // kotlinx.collections.immutable/PersistentList.Builder.build|build(){}[0] @@ -71,14 +94,21 @@ abstract interface <#A: out kotlin/Any?> kotlinx.collections.immutable/Persisten } abstract interface <#A: out kotlin/Any?> kotlinx.collections.immutable/PersistentSet : kotlinx.collections.immutable/ImmutableSet<#A>, kotlinx.collections.immutable/PersistentCollection<#A> { // kotlinx.collections.immutable/PersistentSet|null[0] - abstract fun add(#A): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.add|add(1:0){}[0] - abstract fun addAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.addAll|addAll(kotlin.collections.Collection<1:0>){}[0] + abstract fun adding(#A): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.adding|adding(1:0){}[0] + abstract fun addingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.addingAll|addingAll(kotlin.collections.Collection<1:0>){}[0] abstract fun builder(): kotlinx.collections.immutable/PersistentSet.Builder<#A> // kotlinx.collections.immutable/PersistentSet.builder|builder(){}[0] - abstract fun clear(): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.clear|clear(){}[0] - abstract fun remove(#A): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.remove|remove(1:0){}[0] - abstract fun removeAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.removeAll|removeAll(kotlin.collections.Collection<1:0>){}[0] - abstract fun removeAll(kotlin/Function1<#A, kotlin/Boolean>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.removeAll|removeAll(kotlin.Function1<1:0,kotlin.Boolean>){}[0] - abstract fun retainAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.retainAll|retainAll(kotlin.collections.Collection<1:0>){}[0] + abstract fun cleared(): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.cleared|cleared(){}[0] + abstract fun removing(#A): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.removing|removing(1:0){}[0] + abstract fun removingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.removingAll|removingAll(kotlin.collections.Collection<1:0>){}[0] + abstract fun removingAll(kotlin/Function1<#A, kotlin/Boolean>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.removingAll|removingAll(kotlin.Function1<1:0,kotlin.Boolean>){}[0] + abstract fun retainingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.retainingAll|retainingAll(kotlin.collections.Collection<1:0>){}[0] + open fun add(#A): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.add|add(1:0){}[0] + open fun addAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.addAll|addAll(kotlin.collections.Collection<1:0>){}[0] + open fun clear(): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.clear|clear(){}[0] + open fun remove(#A): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.remove|remove(1:0){}[0] + open fun removeAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.removeAll|removeAll(kotlin.collections.Collection<1:0>){}[0] + open fun removeAll(kotlin/Function1<#A, kotlin/Boolean>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.removeAll|removeAll(kotlin.Function1<1:0,kotlin.Boolean>){}[0] + open fun retainAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentSet<#A> // kotlinx.collections.immutable/PersistentSet.retainAll|retainAll(kotlin.collections.Collection<1:0>){}[0] abstract interface <#A1: kotlin/Any?> Builder : kotlin.collections/MutableSet<#A1>, kotlinx.collections.immutable/PersistentCollection.Builder<#A1> { // kotlinx.collections.immutable/PersistentSet.Builder|null[0] abstract fun build(): kotlinx.collections.immutable/PersistentSet<#A1> // kotlinx.collections.immutable/PersistentSet.Builder.build|build(){}[0] @@ -88,16 +118,16 @@ abstract interface <#A: out kotlin/Any?> kotlinx.collections.immutable/Persisten abstract class <#A: kotlin/Any?> kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList : kotlin.collections/AbstractList<#A>, kotlinx.collections.immutable/PersistentList<#A> { // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList|null[0] constructor () // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.|(){}[0] - open fun addAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.addAll|addAll(kotlin.collections.Collection<1:0>){}[0] - open fun addAll(kotlin/Int, kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.addAll|addAll(kotlin.Int;kotlin.collections.Collection<1:0>){}[0] - open fun clear(): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.clear|clear(){}[0] + open fun addingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.addingAll|addingAll(kotlin.collections.Collection<1:0>){}[0] + open fun addingAll(kotlin/Int, kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.addingAll|addingAll(kotlin.Int;kotlin.collections.Collection<1:0>){}[0] + open fun cleared(): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.cleared|cleared(){}[0] open fun contains(#A): kotlin/Boolean // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.contains|contains(1:0){}[0] open fun containsAll(kotlin.collections/Collection<#A>): kotlin/Boolean // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.containsAll|containsAll(kotlin.collections.Collection<1:0>){}[0] open fun iterator(): kotlin.collections/Iterator<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.iterator|iterator(){}[0] open fun listIterator(): kotlin.collections/ListIterator<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.listIterator|listIterator(){}[0] - open fun remove(#A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.remove|remove(1:0){}[0] - open fun removeAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.removeAll|removeAll(kotlin.collections.Collection<1:0>){}[0] - open fun retainAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.retainAll|retainAll(kotlin.collections.Collection<1:0>){}[0] + open fun removing(#A): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.removing|removing(1:0){}[0] + open fun removingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.removingAll|removingAll(kotlin.collections.Collection<1:0>){}[0] + open fun retainingAll(kotlin.collections/Collection<#A>): kotlinx.collections.immutable/PersistentList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.retainingAll|retainingAll(kotlin.collections.Collection<1:0>){}[0] open fun subList(kotlin/Int, kotlin/Int): kotlinx.collections.immutable/ImmutableList<#A> // kotlinx.collections.immutable.implementations.immutableList/AbstractPersistentList.subList|subList(kotlin.Int;kotlin.Int){}[0] } @@ -184,6 +214,10 @@ final fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.collections.immutable/Pers final fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.collections.immutable/PersistentMap).kotlinx.collections.immutable/putAll(kotlin.collections/Map): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/putAll|putAll@kotlinx.collections.immutable.PersistentMap(kotlin.collections.Map){0§;1§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.collections.immutable/PersistentMap).kotlinx.collections.immutable/putAll(kotlin.sequences/Sequence>): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/putAll|putAll@kotlinx.collections.immutable.PersistentMap(kotlin.sequences.Sequence>){0§;1§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.collections.immutable/PersistentMap).kotlinx.collections.immutable/putAll(kotlin/Array>): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/putAll|putAll@kotlinx.collections.immutable.PersistentMap(kotlin.Array>){0§;1§}[0] +final fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.collections.immutable/PersistentMap).kotlinx.collections.immutable/puttingAll(kotlin.collections/Iterable>): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/puttingAll|puttingAll@kotlinx.collections.immutable.PersistentMap(kotlin.collections.Iterable>){0§;1§}[0] +final fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.collections.immutable/PersistentMap).kotlinx.collections.immutable/puttingAll(kotlin.collections/Map): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/puttingAll|puttingAll@kotlinx.collections.immutable.PersistentMap(kotlin.collections.Map){0§;1§}[0] +final fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.collections.immutable/PersistentMap).kotlinx.collections.immutable/puttingAll(kotlin.sequences/Sequence>): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/puttingAll|puttingAll@kotlinx.collections.immutable.PersistentMap(kotlin.sequences.Sequence>){0§;1§}[0] +final fun <#A: kotlin/Any?, #B: kotlin/Any?> (kotlinx.collections.immutable/PersistentMap).kotlinx.collections.immutable/puttingAll(kotlin/Array>): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/puttingAll|puttingAll@kotlinx.collections.immutable.PersistentMap(kotlin.Array>){0§;1§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?> kotlinx.collections.immutable/immutableHashMapOf(kotlin/Array>...): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/immutableHashMapOf|immutableHashMapOf(kotlin.Array>...){0§;1§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?> kotlinx.collections.immutable/immutableMapOf(kotlin/Array>...): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/immutableMapOf|immutableMapOf(kotlin.Array>...){0§;1§}[0] final fun <#A: kotlin/Any?, #B: kotlin/Any?> kotlinx.collections.immutable/persistentHashMapOf(): kotlinx.collections.immutable/PersistentMap<#A, #B> // kotlinx.collections.immutable/persistentHashMapOf|persistentHashMapOf(){0§;1§}[0] diff --git a/core/commonMain/src/ImmutableCollection.kt b/core/commonMain/src/ImmutableCollection.kt index d36e838a..6624421f 100644 --- a/core/commonMain/src/ImmutableCollection.kt +++ b/core/commonMain/src/ImmutableCollection.kt @@ -29,8 +29,14 @@ public interface PersistentCollection : ImmutableCollection { * Returns the result of adding the specified [element] to this collection. * * @returns a new persistent collection with the specified [element] added; - * or this instance if this collection does not support duplicates and it already contains the element. + * or this instance if this collection does not support duplicates, and it already contains the element. */ + public fun adding(element: @UnsafeVariance E): PersistentCollection + + /** + * See [adding]. + */ + @Deprecated("Use adding() instead.", ReplaceWith("adding(element)")) public fun add(element: @UnsafeVariance E): PersistentCollection /** @@ -39,6 +45,12 @@ public interface PersistentCollection : ImmutableCollection { * @return a new persistent collection with elements of the specified [elements] collection added; * or this instance if no modifications were made in the result of this operation. */ + public fun addingAll(elements: Collection<@UnsafeVariance E>): PersistentCollection + + /** + * See [addingAll]. + */ + @Deprecated("Use addingAll() instead.", ReplaceWith("addingAll(elements)")) public fun addAll(elements: Collection<@UnsafeVariance E>): PersistentCollection /** @@ -47,6 +59,12 @@ public interface PersistentCollection : ImmutableCollection { * @return a new persistent collection with a single appearance of the specified [element] removed; * or this instance if there is no such element in this collection. */ + public fun removing(element: @UnsafeVariance E): PersistentCollection + + /** + * See [removing]. + */ + @Deprecated("Use removing() instead.", ReplaceWith("removing(element)")) public fun remove(element: @UnsafeVariance E): PersistentCollection /** @@ -57,6 +75,12 @@ public interface PersistentCollection : ImmutableCollection { * contained in the specified [elements] collection removed; * or this instance if no modifications were made in the result of this operation. */ + public fun removingAll(elements: Collection<@UnsafeVariance E>): PersistentCollection + + /** + * See [removingAll]. + */ + @Deprecated("Use removingAll() instead.", ReplaceWith("removingAll(elements)")) public fun removeAll(elements: Collection<@UnsafeVariance E>): PersistentCollection /** @@ -65,6 +89,12 @@ public interface PersistentCollection : ImmutableCollection { * @return a new persistent collection with elements matching the specified [predicate] removed; * or this instance if no elements match the predicate. */ + public fun removingAll(predicate: (E) -> Boolean): PersistentCollection + + /** + * See [removingAll]. + */ + @Deprecated("Use removingAll() instead.", ReplaceWith("removingAll(predicate)")) public fun removeAll(predicate: (E) -> Boolean): PersistentCollection /** @@ -75,11 +105,23 @@ public interface PersistentCollection : ImmutableCollection { * contained in the specified [elements] collection; * or this instance if no modifications were made in the result of this operation. */ + public fun retainingAll(elements: Collection<@UnsafeVariance E>): PersistentCollection + + /** + * See [retainingAll]. + */ + @Deprecated("Use retainingAll() instead.", ReplaceWith("retainingAll(elements)")) public fun retainAll(elements: Collection<@UnsafeVariance E>): PersistentCollection /** * Returns an empty persistent collection. */ + public fun cleared(): PersistentCollection + + /** + * See [cleared]. + */ + @Deprecated("Use cleared() instead.", ReplaceWith("cleared()")) public fun clear(): PersistentCollection /** diff --git a/core/commonMain/src/ImmutableList.kt b/core/commonMain/src/ImmutableList.kt index e42ddbc0..2ed25a54 100644 --- a/core/commonMain/src/ImmutableList.kt +++ b/core/commonMain/src/ImmutableList.kt @@ -63,7 +63,13 @@ public interface PersistentList : ImmutableList, PersistentCollection< /** * Returns a new persistent list with the specified [element] appended. */ - override fun add(element: @UnsafeVariance E): PersistentList + override fun adding(element: @UnsafeVariance E): PersistentList + + /** + * See [adding]. + */ + @Deprecated("Use adding() instead.", replaceWith = ReplaceWith("adding(element)")) + override fun add(element: @UnsafeVariance E): PersistentList = adding(element) /** * Returns the result of appending all elements of the specified [elements] collection to this list. @@ -73,7 +79,13 @@ public interface PersistentList : ImmutableList, PersistentCollection< * @return a new persistent list with elements of the specified [elements] collection appended; * or this instance if the specified collection is empty. */ - override fun addAll(elements: Collection<@UnsafeVariance E>): PersistentList // = super.addAll(elements) as ImmutableList + override fun addingAll(elements: Collection<@UnsafeVariance E>): PersistentList // = super.addAll(elements) as ImmutableList + + /** + * See [addingAll]. + */ + @Deprecated("Use addingAll() instead.", replaceWith = ReplaceWith("addingAll(elements)")) + override fun addAll(elements: Collection<@UnsafeVariance E>): PersistentList = addingAll(elements) /** * Returns the result of removing the first appearance of the specified [element] from this list. @@ -81,7 +93,13 @@ public interface PersistentList : ImmutableList, PersistentCollection< * @return a new persistent list with the first appearance of the specified [element] removed; * or this instance if there is no such element in this list. */ - override fun remove(element: @UnsafeVariance E): PersistentList + override fun removing(element: @UnsafeVariance E): PersistentList + + /** + * See [removing]. + */ + @Deprecated("Use removing() instead.", replaceWith = ReplaceWith("removing(element)")) + override fun remove(element: @UnsafeVariance E): PersistentList = removing(element) /** * Returns the result of removing all elements in this list that are also @@ -91,7 +109,13 @@ public interface PersistentList : ImmutableList, PersistentCollection< * contained in the specified [elements] collection removed; * or this instance if no modifications were made in the result of this operation. */ - override fun removeAll(elements: Collection<@UnsafeVariance E>): PersistentList + override fun removingAll(elements: Collection<@UnsafeVariance E>): PersistentList + + /** + * See [removingAll]. + */ + @Deprecated("Use removingAll() instead.", replaceWith = ReplaceWith("removingAll(elements)")) + override fun removeAll(elements: Collection<@UnsafeVariance E>): PersistentList = removingAll(elements) /** * Returns the result of removing all elements in this list that match the specified [predicate]. @@ -99,7 +123,13 @@ public interface PersistentList : ImmutableList, PersistentCollection< * @return a new persistent list with elements matching the specified [predicate] removed; * or this instance if no elements match the predicate. */ - override fun removeAll(predicate: (E) -> Boolean): PersistentList + override fun removingAll(predicate: (E) -> Boolean): PersistentList + + /** + * See [removingAll]. + */ + @Deprecated("Use removingAll() instead.", replaceWith = ReplaceWith("removingAll(predicate)")) + override fun removeAll(predicate: (E) -> Boolean): PersistentList = removingAll(predicate) /** * Returns all elements in this list that are also @@ -109,13 +139,24 @@ public interface PersistentList : ImmutableList, PersistentCollection< * contained in the specified [elements] collection; * or this instance if no modifications were made in the result of this operation. */ - override fun retainAll(elements: Collection<@UnsafeVariance E>): PersistentList + override fun retainingAll(elements: Collection<@UnsafeVariance E>): PersistentList + + /** + * See [retainingAll]. + */ + @Deprecated("Use retainingAll() instead.", replaceWith = ReplaceWith("retainingAll(elements)")) + override fun retainAll(elements: Collection<@UnsafeVariance E>): PersistentList = retainingAll(elements) /** * Returns an empty persistent list. */ - override fun clear(): PersistentList + override fun cleared(): PersistentList + /** + * See [cleared]. + */ + @Deprecated("Use cleared() instead.", replaceWith = ReplaceWith("cleared()")) + override fun clear(): PersistentList = cleared() /** * Returns the result of inserting the specified [c] collection at the specified [index]. @@ -125,28 +166,52 @@ public interface PersistentList : ImmutableList, PersistentCollection< * * @throws IndexOutOfBoundsException if [index] is out of bounds of this list. */ - public fun addAll(index: Int, c: Collection<@UnsafeVariance E>): PersistentList // = builder().apply { addAll(index, c.toList()) }.build() + public fun addingAll(index: Int, c: Collection<@UnsafeVariance E>): PersistentList // = builder().apply { addAll(index, c.toList()) }.build() + + /** + * See [addingAll]. + */ + @Deprecated("Use addingAll(index, c) instead.", replaceWith = ReplaceWith("addingAll(index, c)")) + public fun addAll(index: Int, c: Collection<@UnsafeVariance E>): PersistentList = addingAll(index, c) /** * Returns a new persistent list with the element at the specified [index] replaced with the specified [element]. * * @throws IndexOutOfBoundsException if [index] is out of bounds of this list. */ - public fun set(index: Int, element: @UnsafeVariance E): PersistentList + public fun replacingAt(index: Int, element: @UnsafeVariance E): PersistentList + + /** + * See [replacingAt]. + */ + @Deprecated("Use replacingAt() instead.", replaceWith = ReplaceWith("replacingAt(index, element)")) + public fun set(index: Int, element: @UnsafeVariance E): PersistentList = replacingAt(index, element) /** * Returns a new persistent list with the specified [element] inserted at the specified [index]. * * @throws IndexOutOfBoundsException if [index] is out of bounds of this list. */ - public fun add(index: Int, element: @UnsafeVariance E): PersistentList + public fun adding(index: Int, element: @UnsafeVariance E): PersistentList + + /** + * See [adding]. + */ + @Deprecated("Use adding() instead.", replaceWith = ReplaceWith("adding(index, element)")) + public fun add(index: Int, element: @UnsafeVariance E): PersistentList = adding(index, element) /** * Returns a new persistent list with the element at the specified [index] removed. * * @throws IndexOutOfBoundsException if [index] is out of bounds of this list. */ - public fun removeAt(index: Int): PersistentList + public fun removingAt(index: Int): PersistentList + + /** + * See [removingAt]. + */ + @Deprecated("Use removingAt() instead.", replaceWith = ReplaceWith("removingAt(index)")) + public fun removeAt(index: Int): PersistentList = removingAt(index) /** * A generic builder of the persistent list. Builder exposes its modification operations through the [MutableList] interface. @@ -169,4 +234,4 @@ public interface PersistentList : ImmutableList, PersistentCollection< } override fun builder(): Builder<@UnsafeVariance E> -} \ No newline at end of file +} diff --git a/core/commonMain/src/ImmutableMap.kt b/core/commonMain/src/ImmutableMap.kt index 4b9abc59..b807ee31 100644 --- a/core/commonMain/src/ImmutableMap.kt +++ b/core/commonMain/src/ImmutableMap.kt @@ -47,7 +47,13 @@ public interface PersistentMap : ImmutableMap { * @return a new persistent map with the specified [value] associated with the specified [key]; * or this instance if no modifications were made in the result of this operation. */ - public fun put(key: K, value: @UnsafeVariance V): PersistentMap + public fun putting(key: K, value: @UnsafeVariance V): PersistentMap + + /** + * See [putting]. + */ + @Deprecated("Use putting() instead.", ReplaceWith("putting(key, value)")) + public fun put(key: K, value: @UnsafeVariance V): PersistentMap = putting(key, value) /** * Returns the result of removing the specified [key] and its corresponding value from this map. @@ -55,7 +61,13 @@ public interface PersistentMap : ImmutableMap { * @return a new persistent map with the specified [key] and its corresponding value removed; * or this instance if it contains no mapping for the key. */ - public fun remove(key: K): PersistentMap + public fun removing(key: K): PersistentMap + + /** + * See [removing]. + */ + @Deprecated("Use removing() instead.", ReplaceWith("removing(key)")) + public fun remove(key: K): PersistentMap = removing(key) /** * Returns the result of removing the entry that maps the specified [key] to the specified [value]. @@ -63,7 +75,13 @@ public interface PersistentMap : ImmutableMap { * @return a new persistent map with the entry for the specified [key] and [value] removed; * or this instance if it contains no entry with the specified key and value. */ - public fun remove(key: K, value: @UnsafeVariance V): PersistentMap + public fun removing(key: K, value: @UnsafeVariance V): PersistentMap + + /** + * See [removing]. + */ + @Deprecated("Use removing() instead.", ReplaceWith("removing(key, value)")) + public fun remove(key: K, value: @UnsafeVariance V): PersistentMap = removing(key, value) /** * Returns the result of merging the specified [m] map with this map. @@ -74,12 +92,24 @@ public interface PersistentMap : ImmutableMap { * @return a new persistent map with keys and values from the specified map [m] associated; * or this instance if no modifications were made in the result of this operation. */ - public fun putAll(m: Map): PersistentMap // m: Iterable> or Map or Iterable> + public fun puttingAll(m: Map): PersistentMap // m: Iterable> or Map or Iterable> + + /** + * See [puttingAll]. + */ + @Deprecated("Use puttingAll() instead.", ReplaceWith("puttingAll(m)")) + public fun putAll(m: Map): PersistentMap = puttingAll(m) /** * Returns an empty persistent map. */ - public fun clear(): PersistentMap + public fun cleared(): PersistentMap + + /** + * See [cleared]. + */ + @Deprecated("Use cleared() method instead.", ReplaceWith("cleared()")) + public fun clear(): PersistentMap = cleared() /** * A generic builder of the persistent map. Builder exposes its modification operations through the [MutableMap] interface. diff --git a/core/commonMain/src/ImmutableSet.kt b/core/commonMain/src/ImmutableSet.kt index b53d1c2b..c4f1fd48 100644 --- a/core/commonMain/src/ImmutableSet.kt +++ b/core/commonMain/src/ImmutableSet.kt @@ -33,7 +33,13 @@ public interface PersistentSet : ImmutableSet, PersistentCollection * @return a new persistent set with the specified [element] added; * or this instance if it already contains the element. */ - override fun add(element: @UnsafeVariance E): PersistentSet + override fun adding(element: @UnsafeVariance E): PersistentSet + + /** + * See [adding]. + */ + @Deprecated("Use adding() instead.", replaceWith = ReplaceWith("adding(element)")) + override fun add(element: @UnsafeVariance E): PersistentSet = adding(element) /** * Returns the result of adding all elements of the specified [elements] collection to this set. @@ -41,7 +47,13 @@ public interface PersistentSet : ImmutableSet, PersistentCollection * @return a new persistent set with elements of the specified [elements] collection added; * or this instance if it already contains every element of the specified collection. */ - override fun addAll(elements: Collection<@UnsafeVariance E>): PersistentSet + override fun addingAll(elements: Collection<@UnsafeVariance E>): PersistentSet + + /** + * See [addingAll]. + */ + @Deprecated("Use addingAll() instead.", replaceWith = ReplaceWith("addingAll(elements)")) + override fun addAll(elements: Collection<@UnsafeVariance E>): PersistentSet = addingAll(elements) /** * Returns the result of removing the specified [element] from this set. @@ -49,7 +61,13 @@ public interface PersistentSet : ImmutableSet, PersistentCollection * @return a new persistent set with the specified [element] removed; * or this instance if there is no such element in this set. */ - override fun remove(element: @UnsafeVariance E): PersistentSet + override fun removing(element: @UnsafeVariance E): PersistentSet + + /** + * See [removing]. + */ + @Deprecated("Use removing() instead.", replaceWith = ReplaceWith("removing(element)")) + override fun remove(element: @UnsafeVariance E): PersistentSet = removing(element) /** * Returns the result of removing all elements in this set that are also @@ -59,7 +77,13 @@ public interface PersistentSet : ImmutableSet, PersistentCollection * contained in the specified [elements] collection removed; * or this instance if no modifications were made in the result of this operation. */ - override fun removeAll(elements: Collection<@UnsafeVariance E>): PersistentSet + override fun removingAll(elements: Collection<@UnsafeVariance E>): PersistentSet + + /** + * See [removingAll]. + */ + @Deprecated("Use removingAll() instead.", replaceWith = ReplaceWith("removingAll(elements)")) + override fun removeAll(elements: Collection<@UnsafeVariance E>): PersistentSet = removingAll(elements) /** * Returns the result of removing all elements in this set that match the specified [predicate]. @@ -67,7 +91,13 @@ public interface PersistentSet : ImmutableSet, PersistentCollection * @return a new persistent set with elements matching the specified [predicate] removed; * or this instance if no elements match the predicate. */ - override fun removeAll(predicate: (E) -> Boolean): PersistentSet + override fun removingAll(predicate: (E) -> Boolean): PersistentSet + + /** + * See [removingAll]. + */ + @Deprecated("Use removingAll() instead.", replaceWith = ReplaceWith("removingAll(predicate)")) + override fun removeAll(predicate: (E) -> Boolean): PersistentSet = removingAll(predicate) /** * Returns all elements in this set that are also @@ -77,12 +107,24 @@ public interface PersistentSet : ImmutableSet, PersistentCollection * contained in the specified [elements] collection; * or this instance if no modifications were made in the result of this operation. */ - override fun retainAll(elements: Collection<@UnsafeVariance E>): PersistentSet + override fun retainingAll(elements: Collection<@UnsafeVariance E>): PersistentSet + + /** + * See [retainingAll]. + */ + @Deprecated("Use retainingAll() instead.", replaceWith = ReplaceWith("retainingAll(elements)")) + override fun retainAll(elements: Collection<@UnsafeVariance E>): PersistentSet = retainingAll(elements) /** * Returns an empty persistent set. */ - override fun clear(): PersistentSet + override fun cleared(): PersistentSet + + /** + * See [cleared]. + */ + @Deprecated("Use cleared() instead.", replaceWith = ReplaceWith("cleared()")) + override fun clear(): PersistentSet = cleared() /** * A generic builder of the persistent set. Builder exposes its modification operations through the [MutableSet] interface. @@ -105,4 +147,4 @@ public interface PersistentSet : ImmutableSet, PersistentCollection } override fun builder(): Builder<@UnsafeVariance E> -} \ No newline at end of file +} diff --git a/core/commonMain/src/extensions.kt b/core/commonMain/src/extensions.kt index 57d289fa..b5a0270e 100644 --- a/core/commonMain/src/extensions.kt +++ b/core/commonMain/src/extensions.kt @@ -59,7 +59,7 @@ public inline fun PersistentMap.mutate(mutator: (MutableMap PersistentCollection.plus(element: E): PersistentCollection = add(element) +public inline operator fun PersistentCollection.plus(element: E): PersistentCollection = adding(element) /** * Returns the result of removing a single appearance of the specified [element] from this collection. @@ -67,7 +67,7 @@ public inline operator fun PersistentCollection.plus(element: E): Persist * @return a new persistent collection with a single appearance of the specified [element] removed; * or this instance if there is no such element in this collection. */ -public inline operator fun PersistentCollection.minus(element: E): PersistentCollection = remove(element) +public inline operator fun PersistentCollection.minus(element: E): PersistentCollection = removing(element) /** @@ -77,7 +77,7 @@ public inline operator fun PersistentCollection.minus(element: E): Persis * or this instance if no modifications were made in the result of this operation. */ public operator fun PersistentCollection.plus(elements: Iterable): PersistentCollection - = if (elements is Collection) addAll(elements) else builder().also { it.addAll(elements) }.build() + = if (elements is Collection) addingAll(elements) else builder().also { it.addAll(elements) }.build() /** * Returns the result of adding all elements of the specified [elements] array to this collection. @@ -107,7 +107,7 @@ public operator fun PersistentCollection.plus(elements: Sequence): Per * or this instance if no modifications were made in the result of this operation. */ public operator fun PersistentCollection.minus(elements: Iterable): PersistentCollection - = if (elements is Collection) removeAll(elements) else builder().also { it.removeAll(elements) }.build() + = if (elements is Collection) removingAll(elements) else builder().also { it.removeAll(elements) }.build() /** * Returns the result of removing all elements in this collection that are also @@ -135,7 +135,7 @@ public operator fun PersistentCollection.minus(elements: Sequence): Pe /** * Returns a new persistent list with the specified [element] appended. */ -public inline operator fun PersistentList.plus(element: E): PersistentList = add(element) +public inline operator fun PersistentList.plus(element: E): PersistentList = adding(element) /** * Returns the result of removing the first appearance of the specified [element] from this list. @@ -143,7 +143,7 @@ public inline operator fun PersistentList.plus(element: E): PersistentLis * @return a new persistent list with the first appearance of the specified [element] removed; * or this instance if there is no such element in this list. */ -public inline operator fun PersistentList.minus(element: E): PersistentList = remove(element) +public inline operator fun PersistentList.minus(element: E): PersistentList = removing(element) /** @@ -155,7 +155,7 @@ public inline operator fun PersistentList.minus(element: E): PersistentLi * or this instance if the specified collection is empty. */ public operator fun PersistentList.plus(elements: Iterable): PersistentList - = if (elements is Collection) addAll(elements) else mutate { it.addAll(elements) } + = if (elements is Collection) addingAll(elements) else mutate { it.addAll(elements) } /** * Returns the result of appending all elements of the specified [elements] array to this list. @@ -189,7 +189,7 @@ public operator fun PersistentList.plus(elements: Sequence): Persisten * or this instance if no modifications were made in the result of this operation. */ public operator fun PersistentList.minus(elements: Iterable): PersistentList - = if (elements is Collection) removeAll(elements) else mutate { it.removeAll(elements) } + = if (elements is Collection) removingAll(elements) else mutate { it.removeAll(elements) } /** * Returns the result of removing all elements in this list that are also @@ -220,7 +220,7 @@ public operator fun PersistentList.minus(elements: Sequence): Persiste * @return a new persistent set with the specified [element] added; * or this instance if it already contains the element. */ -public inline operator fun PersistentSet.plus(element: E): PersistentSet = add(element) +public inline operator fun PersistentSet.plus(element: E): PersistentSet = adding(element) /** * Returns the result of removing the specified [element] from this set. @@ -228,7 +228,7 @@ public inline operator fun PersistentSet.plus(element: E): PersistentSet< * @return a new persistent set with the specified [element] removed; * or this instance if there is no such element in this set. */ -public inline operator fun PersistentSet.minus(element: E): PersistentSet = remove(element) +public inline operator fun PersistentSet.minus(element: E): PersistentSet = removing(element) /** @@ -238,7 +238,7 @@ public inline operator fun PersistentSet.minus(element: E): PersistentSet * or this instance if it already contains every element of the specified collection. */ public operator fun PersistentSet.plus(elements: Iterable): PersistentSet - = if (elements is Collection) addAll(elements) else mutate { it.addAll(elements) } + = if (elements is Collection) addingAll(elements) else mutate { it.addAll(elements) } /** * Returns the result of adding all elements of the specified [elements] array to this set. @@ -268,7 +268,7 @@ public operator fun PersistentSet.plus(elements: Sequence): Persistent * or this instance if no modifications were made in the result of this operation. */ public operator fun PersistentSet.minus(elements: Iterable): PersistentSet - = if (elements is Collection) removeAll(elements) else mutate { it.removeAll(elements) } + = if (elements is Collection) removingAll(elements) else mutate { it.removeAll(elements) } /** * Returns the result of removing all elements in this set that are also @@ -301,7 +301,7 @@ public operator fun PersistentSet.minus(elements: Sequence): Persisten * or this instance if no modifications were made in the result of this operation. */ public infix fun PersistentSet.intersect(elements: Iterable): PersistentSet - = if (elements is Collection) retainAll(elements) else mutate { it.retainAll(elements) } + = if (elements is Collection) retainingAll(elements) else mutate { it.retainAll(elements) } /** * Returns all elements in this collection that are also @@ -324,7 +324,7 @@ public infix fun PersistentCollection.intersect(elements: Iterable): P */ @Suppress("UNCHECKED_CAST") public inline operator fun PersistentMap.plus(pair: Pair): PersistentMap - = (this as PersistentMap).put(pair.first, pair.second) + = (this as PersistentMap).putting(pair.first, pair.second) /** * Returns the result of replacing or adding entries to this map from the specified key-value pairs. @@ -332,7 +332,7 @@ public inline operator fun PersistentMap.plus(pair: Pair) * @return a new persistent map with entries from the specified key-value pairs added; * or this instance if no modifications were made in the result of this operation. */ -public inline operator fun PersistentMap.plus(pairs: Iterable>): PersistentMap = putAll(pairs) +public inline operator fun PersistentMap.plus(pairs: Iterable>): PersistentMap = puttingAll(pairs) /** * Returns the result of replacing or adding entries to this map from the specified key-value pairs. @@ -340,7 +340,7 @@ public inline operator fun PersistentMap.plus(pairs: Iterable

PersistentMap.plus(pairs: Array>): PersistentMap = putAll(pairs) +public inline operator fun PersistentMap.plus(pairs: Array>): PersistentMap = puttingAll(pairs) /** * Returns the result of replacing or adding entries to this map from the specified key-value pairs. @@ -348,7 +348,7 @@ public inline operator fun PersistentMap.plus(pairs: Array PersistentMap.plus(pairs: Sequence>): PersistentMap = putAll(pairs) +public inline operator fun PersistentMap.plus(pairs: Sequence>): PersistentMap = puttingAll(pairs) /** * Returns the result of merging the specified [map] with this map. @@ -359,7 +359,7 @@ public inline operator fun PersistentMap.plus(pairs: Sequence

PersistentMap.plus(map: Map): PersistentMap = putAll(map) +public inline operator fun PersistentMap.plus(map: Map): PersistentMap = puttingAll(map) /** @@ -372,8 +372,15 @@ public inline operator fun PersistentMap.plus(map: Map PersistentMap.putAll(map: Map): PersistentMap = - (this as PersistentMap).putAll(map) +public fun PersistentMap.puttingAll(map: Map): PersistentMap = + (this as PersistentMap).puttingAll(map) + +/** + * See [puttingAll]. + */ +@Deprecated("Use puttingAll() instead.", ReplaceWith("puttingAll(map)")) +@Suppress("UNCHECKED_CAST") +public fun PersistentMap.putAll(map: Map): PersistentMap = puttingAll(map) /** * Returns the result of replacing or adding entries to this map from the specified key-value pairs. @@ -381,27 +388,44 @@ public fun PersistentMap.putAll(map: Map): Persistent * @return a new persistent map with entries from the specified key-value pairs added; * or this instance if no modifications were made in the result of this operation. */ -public fun PersistentMap.putAll(pairs: Iterable>): PersistentMap +public fun PersistentMap.puttingAll(pairs: Iterable>): PersistentMap = mutate { it.putAll(pairs) } +/** + * See [puttingAll]. + */ +@Deprecated("Use puttingAll() instead.", ReplaceWith("puttingAll(pairs)")) +public fun PersistentMap.putAll(pairs: Iterable>): PersistentMap = puttingAll(pairs) + /** * Returns the result of replacing or adding entries to this map from the specified key-value pairs. * * @return a new persistent map with entries from the specified key-value pairs added; * or this instance if no modifications were made in the result of this operation. */ -public fun PersistentMap.putAll(pairs: Array>): PersistentMap +public fun PersistentMap.puttingAll(pairs: Array>): PersistentMap = mutate { it.putAll(pairs) } +/** + * See [puttingAll]. + */ +@Deprecated("Use puttingAll() instead.", ReplaceWith("puttingAll(pairs)")) +public fun PersistentMap.putAll(pairs: Array>): PersistentMap = puttingAll(pairs) + /** * Returns the result of replacing or adding entries to this map from the specified key-value pairs. * * @return a new persistent map with entries from the specified key-value pairs added; * or this instance if no modifications were made in the result of this operation. */ -public fun PersistentMap.putAll(pairs: Sequence>): PersistentMap +public fun PersistentMap.puttingAll(pairs: Sequence>): PersistentMap = mutate { it.putAll(pairs) } +/** + * See [puttingAll]. + */ +@Deprecated("Use puttingAll() instead.", ReplaceWith("puttingAll(pairs)")) +public fun PersistentMap.putAll(pairs: Sequence>): PersistentMap = puttingAll(pairs) /** * Returns the result of removing the specified [key] and its corresponding value from this map. @@ -411,7 +435,7 @@ public fun PersistentMap.putAll(pairs: Sequence>): P */ @Suppress("UNCHECKED_CAST") public operator fun PersistentMap.minus(key: K): PersistentMap - = (this as PersistentMap).remove(key) + = (this as PersistentMap).removing(key) /** * Returns the result of removing the specified [keys] and their corresponding values from this map. @@ -444,7 +468,7 @@ public operator fun PersistentMap.minus(keys: Sequence): Per /** * Returns a new persistent list of the specified elements. */ -public fun persistentListOf(vararg elements: E): PersistentList = persistentVectorOf().addAll(elements.asList()) +public fun persistentListOf(vararg elements: E): PersistentList = persistentVectorOf().addingAll(elements.asList()) /** * Returns an empty persistent list. @@ -457,7 +481,7 @@ public fun persistentListOf(): PersistentList = persistentVectorOf() * * Elements of the returned set are iterated in the order they were specified. */ -public fun persistentSetOf(vararg elements: E): PersistentSet = PersistentOrderedSet.emptyOf().addAll(elements.asList()) +public fun persistentSetOf(vararg elements: E): PersistentSet = PersistentOrderedSet.emptyOf().addingAll(elements.asList()) /** * Returns an empty persistent set. @@ -470,7 +494,7 @@ public fun persistentSetOf(): PersistentSet = PersistentOrderedSet.emptyO * * Order of the elements in the returned set is unspecified. */ -public fun persistentHashSetOf(vararg elements: E): PersistentSet = PersistentHashSet.emptyOf().addAll(elements.asList()) +public fun persistentHashSetOf(vararg elements: E): PersistentSet = PersistentHashSet.emptyOf().addingAll(elements.asList()) /** * Returns an empty persistent set. @@ -739,7 +763,7 @@ public fun CharSequence.toPersistentHashSet(): PersistentSet = public fun Map.toImmutableMap(): ImmutableMap = this as? ImmutableMap ?: (this as? PersistentMap.Builder)?.build() - ?: persistentMapOf().putAll(this) + ?: persistentMapOf().puttingAll(this) /** * Returns a persistent map containing all entries from this map. @@ -752,7 +776,7 @@ public fun Map.toImmutableMap(): ImmutableMap public fun Map.toPersistentMap(): PersistentMap = this as? PersistentOrderedMap ?: (this as? PersistentOrderedMapBuilder)?.build() - ?: PersistentOrderedMap.emptyOf().putAll(this) + ?: PersistentOrderedMap.emptyOf().puttingAll(this) /** * Returns an immutable map containing all entries from this map. @@ -765,4 +789,4 @@ public fun Map.toPersistentMap(): PersistentMap public fun Map.toPersistentHashMap(): PersistentMap = this as? PersistentHashMap ?: (this as? PersistentHashMapBuilder)?.build() - ?: PersistentHashMap.emptyOf().putAll(this) + ?: PersistentHashMap.emptyOf().puttingAll(this) diff --git a/core/commonMain/src/implementations/immutableList/AbstractPersistentList.kt b/core/commonMain/src/implementations/immutableList/AbstractPersistentList.kt index 525e59b5..fe41cf17 100644 --- a/core/commonMain/src/implementations/immutableList/AbstractPersistentList.kt +++ b/core/commonMain/src/implementations/immutableList/AbstractPersistentList.kt @@ -15,36 +15,36 @@ public abstract class AbstractPersistentList : PersistentList, AbstractLis return super.subList(fromIndex, toIndex) } - override fun addAll(elements: Collection): PersistentList { + override fun addingAll(elements: Collection): PersistentList { if (elements.isEmpty()) return this return mutate { it.addAll(elements) } } - override fun addAll(index: Int, c: Collection): PersistentList { + override fun addingAll(index: Int, c: Collection): PersistentList { checkPositionIndex(index, size) if (c.isEmpty()) return this return mutate { it.addAll(index, c) } } - override fun remove(element: E): PersistentList { + override fun removing(element: E): PersistentList { val index = this.indexOf(element) if (index != -1) { - return this.removeAt(index) + return this.removingAt(index) } return this } - override fun removeAll(elements: Collection): PersistentList { + override fun removingAll(elements: Collection): PersistentList { if (elements.isEmpty()) return this - return removeAll { elements.contains(it) } + return removingAll { elements.contains(it) } } - override fun retainAll(elements: Collection): PersistentList { + override fun retainingAll(elements: Collection): PersistentList { if (elements.isEmpty()) return persistentVectorOf() - return removeAll { !elements.contains(it) } + return removingAll { !elements.contains(it) } } - override fun clear(): PersistentList { + override fun cleared(): PersistentList { return persistentVectorOf() } @@ -63,4 +63,4 @@ public abstract class AbstractPersistentList : PersistentList, AbstractLis override fun listIterator(): ListIterator { return this.listIterator(0) } -} \ No newline at end of file +} diff --git a/core/commonMain/src/implementations/immutableList/PersistentVector.kt b/core/commonMain/src/implementations/immutableList/PersistentVector.kt index 7f7e805e..2cd61e12 100644 --- a/core/commonMain/src/implementations/immutableList/PersistentVector.kt +++ b/core/commonMain/src/implementations/immutableList/PersistentVector.kt @@ -32,7 +32,7 @@ internal class PersistentVector(private val root: Array, private fun rootSize(): Int = rootSize(size) - override fun add(element: E): PersistentList { + override fun adding(element: E): PersistentList { val tailSize = size - rootSize() if (tailSize < MAX_BUFFER_SIZE) { val newTail = tail.copyOf(MAX_BUFFER_SIZE) @@ -78,10 +78,10 @@ internal class PersistentVector(private val root: Array, return newRootNode } - override fun add(index: Int, element: E): PersistentList { + override fun adding(index: Int, element: E): PersistentList { checkPositionIndex(index, size) if (index == size) { - return add(element) + return adding(element) } val rootSize = rootSize() @@ -143,7 +143,7 @@ internal class PersistentVector(private val root: Array, return newRoot } - override fun removeAt(index: Int): PersistentList { + override fun removingAt(index: Int): PersistentList { checkElementIndex(index, size) val rootSize = rootSize() if (index >= rootSize) { @@ -259,7 +259,7 @@ internal class PersistentVector(private val root: Array, return newRoot } - override fun removeAll(predicate: (E) -> Boolean): PersistentList { + override fun removingAll(predicate: (E) -> Boolean): PersistentList { return builder().also { it.removeAllWithPredicate(predicate) }.build() } @@ -296,7 +296,7 @@ internal class PersistentVector(private val root: Array, return buffer[index and MAX_BUFFER_SIZE_MINUS_ONE] as E } - override fun set(index: Int, element: E): PersistentList { + override fun replacingAt(index: Int, element: E): PersistentList { checkElementIndex(index, size) if (rootSize() <= index) { val newTail = tail.copyOf(MAX_BUFFER_SIZE) diff --git a/core/commonMain/src/implementations/immutableList/SmallPersistentVector.kt b/core/commonMain/src/implementations/immutableList/SmallPersistentVector.kt index 7072814c..bb8b6e25 100644 --- a/core/commonMain/src/implementations/immutableList/SmallPersistentVector.kt +++ b/core/commonMain/src/implementations/immutableList/SmallPersistentVector.kt @@ -24,7 +24,7 @@ internal class SmallPersistentVector(private val buffer: Array) : Abstr return arrayOfNulls(size) } - override fun add(element: E): PersistentList { + override fun adding(element: E): PersistentList { if (size < MAX_BUFFER_SIZE) { val newBuffer = buffer.copyOf(size + 1) newBuffer[size] = element @@ -34,7 +34,7 @@ internal class SmallPersistentVector(private val buffer: Array) : Abstr return PersistentVector(buffer, tail, size + 1, 0) } - override fun addAll(elements: Collection): PersistentList { + override fun addingAll(elements: Collection): PersistentList { if (elements.isEmpty()) return this if (size + elements.size <= MAX_BUFFER_SIZE) { val newBuffer = buffer.copyOf(size + elements.size) @@ -48,7 +48,7 @@ internal class SmallPersistentVector(private val buffer: Array) : Abstr return mutate { it.addAll(elements) } } - override fun removeAll(predicate: (E) -> Boolean): PersistentList { + override fun removingAll(predicate: (E) -> Boolean): PersistentList { var newSize = size var removeMask = 0 @@ -78,7 +78,7 @@ internal class SmallPersistentVector(private val buffer: Array) : Abstr } } - override fun addAll(index: Int, c: Collection): PersistentList { + override fun addingAll(index: Int, c: Collection): PersistentList { checkPositionIndex(index, size) if (c.isEmpty()) return this if (size + c.size <= MAX_BUFFER_SIZE) { @@ -94,10 +94,10 @@ internal class SmallPersistentVector(private val buffer: Array) : Abstr return mutate { it.addAll(index, c) } } - override fun add(index: Int, element: E): PersistentList { + override fun adding(index: Int, element: E): PersistentList { checkPositionIndex(index, size) if (index == size) { - return add(element) + return adding(element) } if (size < MAX_BUFFER_SIZE) { @@ -116,7 +116,7 @@ internal class SmallPersistentVector(private val buffer: Array) : Abstr return PersistentVector(root, tail, size + 1, 0) } - override fun removeAt(index: Int): PersistentList { + override fun removingAt(index: Int): PersistentList { checkElementIndex(index, size) if (size == 1) { return EMPTY @@ -151,7 +151,7 @@ internal class SmallPersistentVector(private val buffer: Array) : Abstr return buffer[index] as E } - override fun set(index: Int, element: E): PersistentList { + override fun replacingAt(index: Int, element: E): PersistentList { checkElementIndex(index, size) val newBuffer = buffer.copyOf() newBuffer[index] = element diff --git a/core/commonMain/src/implementations/immutableMap/PersistentHashMap.kt b/core/commonMain/src/implementations/immutableMap/PersistentHashMap.kt index e798d483..5bdb8757 100644 --- a/core/commonMain/src/implementations/immutableMap/PersistentHashMap.kt +++ b/core/commonMain/src/implementations/immutableMap/PersistentHashMap.kt @@ -48,31 +48,31 @@ internal class PersistentHashMap(internal val node: TrieNode, return node.get(key.hashCode(), key, 0) } - override fun put(key: K, value: @UnsafeVariance V): PersistentHashMap { + override fun putting(key: K, value: @UnsafeVariance V): PersistentHashMap { val newNodeResult = node.put(key.hashCode(), key, value, 0) ?: return this return PersistentHashMap(newNodeResult.node, size + newNodeResult.sizeDelta) } - override fun remove(key: K): PersistentHashMap { + override fun removing(key: K): PersistentHashMap { val newNode = node.remove(key.hashCode(), key, 0) if (node === newNode) { return this } if (newNode == null) { return emptyOf() } return PersistentHashMap(newNode, size - 1) } - override fun remove(key: K, value: @UnsafeVariance V): PersistentHashMap { + override fun removing(key: K, value: @UnsafeVariance V): PersistentHashMap { val newNode = node.remove(key.hashCode(), key, value, 0) if (node === newNode) { return this } if (newNode == null) { return emptyOf() } return PersistentHashMap(newNode, size - 1) } - override fun putAll(m: Map): PersistentMap { + override fun puttingAll(m: Map): PersistentMap { if (m.isEmpty()) return this return this.mutate { it.putAll(m) } } - override fun clear(): PersistentMap { + override fun cleared(): PersistentMap { return PersistentHashMap.emptyOf() } @@ -117,4 +117,4 @@ internal class PersistentHashMap(internal val node: TrieNode, @Suppress("UNCHECKED_CAST") internal fun emptyOf(): PersistentHashMap = EMPTY as PersistentHashMap } -} \ No newline at end of file +} diff --git a/core/commonMain/src/implementations/immutableSet/PersistentHashSet.kt b/core/commonMain/src/implementations/immutableSet/PersistentHashSet.kt index 7ac2a461..a7ebbe32 100644 --- a/core/commonMain/src/implementations/immutableSet/PersistentHashSet.kt +++ b/core/commonMain/src/implementations/immutableSet/PersistentHashSet.kt @@ -14,33 +14,33 @@ internal class PersistentHashSet(internal val node: TrieNode, return node.contains(element.hashCode(), element, 0) } - override fun add(element: E): PersistentSet { + override fun adding(element: E): PersistentSet { val newNode = node.add(element.hashCode(), element, 0) if (node === newNode) { return this } return PersistentHashSet(newNode, size + 1) } - override fun addAll(elements: Collection): PersistentSet { + override fun addingAll(elements: Collection): PersistentSet { if (elements.isEmpty()) return this return this.mutate { it.addAll(elements) } } - override fun remove(element: E): PersistentSet { + override fun removing(element: E): PersistentSet { val newNode = node.remove(element.hashCode(), element, 0) if (node === newNode) { return this } return PersistentHashSet(newNode, size - 1) } - override fun removeAll(elements: Collection): PersistentSet { + override fun removingAll(elements: Collection): PersistentSet { if (elements.isEmpty()) return this return mutate { it.removeAll(elements) } } - override fun removeAll(predicate: (E) -> Boolean): PersistentSet { + override fun removingAll(predicate: (E) -> Boolean): PersistentSet { return mutate { it.removeAll(predicate) } } - override fun retainAll(elements: Collection): PersistentSet { + override fun retainingAll(elements: Collection): PersistentSet { if (elements.isEmpty()) return PersistentHashSet.emptyOf() return mutate { it.retainAll(elements) } } @@ -55,7 +55,7 @@ internal class PersistentHashSet(internal val node: TrieNode, return super.containsAll(elements) } - override fun clear(): PersistentSet { + override fun cleared(): PersistentSet { return PersistentHashSet.emptyOf() } diff --git a/core/commonMain/src/implementations/persistentOrderedMap/PersistentOrderedMap.kt b/core/commonMain/src/implementations/persistentOrderedMap/PersistentOrderedMap.kt index 5f7df084..c33feb17 100644 --- a/core/commonMain/src/implementations/persistentOrderedMap/PersistentOrderedMap.kt +++ b/core/commonMain/src/implementations/persistentOrderedMap/PersistentOrderedMap.kt @@ -64,9 +64,9 @@ internal class PersistentOrderedMap( override fun get(key: K): V? = hashMap[key]?.value - override fun put(key: K, value: @UnsafeVariance V): PersistentOrderedMap { + override fun putting(key: K, value: @UnsafeVariance V): PersistentOrderedMap { if (isEmpty()) { - val newMap = hashMap.put(key, LinkedValue(value)) + val newMap = hashMap.putting(key, LinkedValue(value)) return PersistentOrderedMap(key, key, newMap) } @@ -75,7 +75,7 @@ internal class PersistentOrderedMap( if (links.value === value) { return this } - val newMap = hashMap.put(key, links.withValue(value)) + val newMap = hashMap.putting(key, links.withValue(value)) return PersistentOrderedMap(firstKey, lastKey, newMap) } @@ -84,26 +84,26 @@ internal class PersistentOrderedMap( val lastLinks = hashMap[lastKey]!! // assert(!lastLink.hasNext) val newMap = hashMap - .put(lastKey, lastLinks.withNext(key)) - .put(key, LinkedValue(value, previous = lastKey)) + .putting(lastKey, lastLinks.withNext(key)) + .putting(key, LinkedValue(value, previous = lastKey)) return PersistentOrderedMap(firstKey, key, newMap) } - override fun remove(key: K): PersistentOrderedMap { + override fun removing(key: K): PersistentOrderedMap { val links = hashMap[key] ?: return this - var newMap = hashMap.remove(key) + var newMap = hashMap.removing(key) if (links.hasPrevious) { val previousLinks = newMap[links.previous]!! // assert(previousLinks.next == key) @Suppress("UNCHECKED_CAST") - newMap = newMap.put(links.previous as K, previousLinks.withNext(links.next)) + newMap = newMap.putting(links.previous as K, previousLinks.withNext(links.next)) } if (links.hasNext) { val nextLinks = newMap[links.next]!! // assert(nextLinks.previous == key) @Suppress("UNCHECKED_CAST") - newMap = newMap.put(links.next as K, nextLinks.withPrevious(links.previous)) + newMap = newMap.putting(links.next as K, nextLinks.withPrevious(links.previous)) } val newFirstKey = if (!links.hasPrevious) links.next else firstKey @@ -111,17 +111,17 @@ internal class PersistentOrderedMap( return PersistentOrderedMap(newFirstKey, newLastKey, newMap) } - override fun remove(key: K, value: @UnsafeVariance V): PersistentOrderedMap { + override fun removing(key: K, value: @UnsafeVariance V): PersistentOrderedMap { val links = hashMap[key] ?: return this - return if (links.value == value) this.remove(key) else this + return if (links.value == value) this.removing(key) else this } - override fun putAll(m: Map): PersistentMap { + override fun puttingAll(m: Map): PersistentMap { if (m.isEmpty()) return this return this.mutate { it.putAll(m) } } - override fun clear(): PersistentMap { + override fun cleared(): PersistentMap { return emptyOf() } @@ -170,4 +170,4 @@ internal class PersistentOrderedMap( @Suppress("UNCHECKED_CAST") internal fun emptyOf(): PersistentOrderedMap = EMPTY as PersistentOrderedMap } -} \ No newline at end of file +} diff --git a/core/commonMain/src/implementations/persistentOrderedSet/PersistentOrderedSet.kt b/core/commonMain/src/implementations/persistentOrderedSet/PersistentOrderedSet.kt index 54bc6e72..b46c3324 100644 --- a/core/commonMain/src/implementations/persistentOrderedSet/PersistentOrderedSet.kt +++ b/core/commonMain/src/implementations/persistentOrderedSet/PersistentOrderedSet.kt @@ -33,12 +33,12 @@ internal class PersistentOrderedSet( override fun contains(element: E): Boolean = hashMap.containsKey(element) - override fun add(element: E): PersistentSet { + override fun adding(element: E): PersistentSet { if (hashMap.containsKey(element)) { return this } if (isEmpty()) { - val newMap = hashMap.put(element, Links()) + val newMap = hashMap.putting(element, Links()) return PersistentOrderedSet(element, element, newMap) } @Suppress("UNCHECKED_CAST") @@ -47,52 +47,52 @@ internal class PersistentOrderedSet( // assert(!lastLinks.hasNext) val newMap = hashMap - .put(lastElement, lastLinks.withNext(element)) - .put(element, Links(previous = lastElement)) + .putting(lastElement, lastLinks.withNext(element)) + .putting(element, Links(previous = lastElement)) return PersistentOrderedSet(firstElement, element, newMap) } - override fun addAll(elements: Collection): PersistentSet { + override fun addingAll(elements: Collection): PersistentSet { if (elements.isEmpty()) return this return this.mutate { it.addAll(elements) } } - override fun remove(element: E): PersistentSet { + override fun removing(element: E): PersistentSet { val links = hashMap[element] ?: return this - var newMap = hashMap.remove(element) + var newMap = hashMap.removing(element) if (links.hasPrevious) { val previousLinks = newMap[links.previous]!! // assert(previousLinks.next == element) @Suppress("UNCHECKED_CAST") - newMap = newMap.put(links.previous as E, previousLinks.withNext(links.next)) + newMap = newMap.putting(links.previous as E, previousLinks.withNext(links.next)) } if (links.hasNext) { val nextLinks = newMap[links.next]!! // assert(nextLinks.previous == element) @Suppress("UNCHECKED_CAST") - newMap = newMap.put(links.next as E, nextLinks.withPrevious(links.previous)) + newMap = newMap.putting(links.next as E, nextLinks.withPrevious(links.previous)) } val newFirstElement = if (!links.hasPrevious) links.next else firstElement val newLastElement = if (!links.hasNext) links.previous else lastElement return PersistentOrderedSet(newFirstElement, newLastElement, newMap) } - override fun removeAll(elements: Collection): PersistentSet { + override fun removingAll(elements: Collection): PersistentSet { if (elements.isEmpty()) return this return mutate { it.removeAll(elements) } } - override fun removeAll(predicate: (E) -> Boolean): PersistentSet { + override fun removingAll(predicate: (E) -> Boolean): PersistentSet { return mutate { it.removeAll(predicate) } } - override fun retainAll(elements: Collection): PersistentSet { + override fun retainingAll(elements: Collection): PersistentSet { if (elements.isEmpty()) return PersistentOrderedSet.emptyOf() return mutate { it.retainAll(elements) } } - override fun clear(): PersistentSet { + override fun cleared(): PersistentSet { return PersistentOrderedSet.emptyOf() } diff --git a/core/commonTest/src/contract/list/ImmutableListTest.kt b/core/commonTest/src/contract/list/ImmutableListTest.kt index 76883a04..290504c1 100644 --- a/core/commonTest/src/contract/list/ImmutableListTest.kt +++ b/core/commonTest/src/contract/list/ImmutableListTest.kt @@ -35,7 +35,7 @@ class ImmutableListTest { *(1..1885).map { it }.toTypedArray() ) - xs = xs.removeAll( + xs = xs.removingAll( (1..1837).map { it } ) @@ -64,7 +64,7 @@ class ImmutableListTest { list.removeAt(0) assertNotEquals>(list, immList) - immList = immList.toPersistentList().removeAt(0) + immList = immList.toPersistentList().removingAt(0) compareLists(list, immList) } @@ -77,10 +77,10 @@ class ImmutableListTest { @Test fun addElements() { var list = persistentListOf() - list = list.add("x") - list = list.add(0, "a") - list = list.addAll(list) - list = list.addAll(1, listOf("b", "c")) + list = list.adding("x") + list = list.adding(0, "a") + list = list.addingAll(list) + list = list.addingAll(1, listOf("b", "c")) list = list + "y" list += "z" list += arrayOf("1", "2").asIterable() @@ -91,12 +91,12 @@ class ImmutableListTest { var list = "abcxaxab12".toImmutableList().toPersistentList() for (i in list.indices) { - list = list.set(i, list[i] + i) + list = list.replacingAt(i, list[i] + i) } assertEquals("ace{e}gi9;", list.joinToString("")) - assertFailsWith { list.set(-1, '0') } - assertFailsWith { list.set(list.size + 1, '0') } + assertFailsWith { list.replacingAt(-1, '0') } + assertFailsWith { list.replacingAt(list.size + 1, '0') } } @Test fun removeElements() { @@ -105,22 +105,22 @@ class ImmutableListTest { compareLists(content.toList(), list) } - expectList("bcxaxyz12", list.removeAt(0)) - expectList("abcaxyz12", list.remove('x')) + expectList("bcxaxyz12", list.removingAt(0)) + expectList("abcaxyz12", list.removing('x')) expectList("abcaxyz12", list - 'x') - expectList("abcayz12", list.removeAll(listOf('x'))) + expectList("abcayz12", list.removingAll(listOf('x'))) expectList("abcayz12", list - listOf('x')) - expectList("abcxaxyz", list.removeAll { it.isDigit() }) + expectList("abcxaxyz", list.removingAll { it.isDigit() }) assertEquals(emptyList(), list - list) - assertEquals(emptyList(), list.clear()) + assertEquals(emptyList(), list.cleared()) } @Test fun smallPersistentListFromMutableBuffer() { val list = List(33) { it } var vector = persistentListOf().mutate { it.addAll(list) } - vector = vector.removeAt(vector.lastIndex) + vector = vector.removingAt(vector.lastIndex) assertEquals(list.dropLast(1), vector) } @@ -194,16 +194,16 @@ class ImmutableListTest { } @Test fun noOperation() { - persistentListOf().testNoOperation({ clear() }, { clear() }) + persistentListOf().testNoOperation({ cleared() }, { clear() }) val list = "abcxaxyz12".toPersistentList() with(list) { - testNoOperation({ remove('d') }, { remove('d') }) - testNoOperation({ removeAll(listOf('d', 'e')) }, { removeAll(listOf('d', 'e')) }) - testNoOperation({ removeAll { it.isUpperCase() } }, { removeAll { it.isUpperCase() } }) - testNoOperation({ removeAll(emptyList()) }, { removeAll(emptyList())}) - testNoOperation({ addAll(emptyList()) }, { addAll(emptyList())}) - testNoOperation({ addAll(2, emptyList()) }, { addAll(2, emptyList())}) + testNoOperation({ removing('d') }, { remove('d') }) + testNoOperation({ removingAll(listOf('d', 'e')) }, { removeAll(listOf('d', 'e')) }) + testNoOperation({ removingAll { it.isUpperCase() } }, { removeAll { it.isUpperCase() } }) + testNoOperation({ removingAll(emptyList()) }, { removeAll(emptyList())}) + testNoOperation({ addingAll(emptyList()) }, { addAll(emptyList())}) + testNoOperation({ addingAll(2, emptyList()) }, { addAll(2, emptyList())}) } } @@ -224,4 +224,4 @@ class ImmutableListTest { assertEquals>(listOf("x", null, 1), listAny) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/contract/map/ImmutableMapTest.kt b/core/commonTest/src/contract/map/ImmutableMapTest.kt index d204d443..3399d68b 100644 --- a/core/commonTest/src/contract/map/ImmutableMapTest.kt +++ b/core/commonTest/src/contract/map/ImmutableMapTest.kt @@ -24,27 +24,27 @@ class ImmutableHashMapTest : ImmutableMapTest() { @Test fun putAllElements() { run { val x = immutableMapOf() + (11..200).map { "$it" to it } - compareMaps(x.toMap(), x.putAll(immutableMapOf())) - compareMaps(x.toMap(), immutableMapOf().putAll(x)) + compareMaps(x.toMap(), x.puttingAll(immutableMapOf())) + compareMaps(x.toMap(), immutableMapOf().puttingAll(x)) } run { val x = immutableMapOf() + (11..200).map { it to it } val y = immutableMapOf() + (120..400).map { it to it } - compareMaps(x.toMap() + y.toMap(), x.putAll(y)) + compareMaps(x.toMap() + y.toMap(), x.puttingAll(y)) } run { val x = immutableMapOf() + (11..200).map { "$it" to it } val y = immutableMapOf() + (120..400).map { "$it" to it } - compareMaps(x.toMap() + y.toMap(), x.putAll(y)) + compareMaps(x.toMap() + y.toMap(), x.puttingAll(y)) } run { val x = immutableMapOf() + (11..200).map { IntWrapper(it, it % 30) to it } val y = immutableMapOf() + (120..400).map { IntWrapper(it, it % 30) to it } - compareMaps(x.toMap() + y.toMap(), x.putAll(y)) - compareMaps(y.toMap() + x.toMap(), y.putAll(x)) + compareMaps(x.toMap() + y.toMap(), x.puttingAll(y)) + compareMaps(y.toMap() + x.toMap(), y.puttingAll(x)) } run { @@ -80,7 +80,7 @@ class ImmutableHashMapTest : ImmutableMapTest() { @Test fun regressionGithubIssue109() { // https://github.com/Kotlin/kotlinx.collections.immutable/issues/109 - val map0 = immutableMapOf().put(0, 0).put(1, 1).put(32, 32) + val map0 = immutableMapOf().putting(0, 0).putting(1, 1).putting(32, 32) val map1 = map0.mutate { it.remove(0) } map1.mutate { it.remove(1) @@ -115,7 +115,7 @@ class ImmutableOrderedMapTest : ImmutableMapTest() { map += "x" to 1 compare(setOf("x", "y"), map.keys) { setBehavior(ordered = true) } - map = map.remove("x") + map = map.removing("x") map += "x" to 2 compare(setOf("y", "x"), map.keys) { setBehavior(ordered = true) } compare(listOf(1, 2), map.values) { collectionBehavior(ordered = true) } @@ -187,7 +187,7 @@ abstract class ImmutableMapTest { map.remove(null) assertNotEquals>(map, immMap) - immMap = immMap.remove(null) + immMap = immMap.removing(null) assertEquals>(map, immMap) // problem } @@ -200,9 +200,9 @@ abstract class ImmutableMapTest { @Test fun putElements() { var map = immutableMapOf().toPersistentMap() - map = map.put("x", 0) - map = map.put("x", 1) - map = map.putAll(arrayOf("x" to null)) + map = map.putting("x", 0) + map = map.putting("x", 1) + map = map.puttingAll(arrayOf("x" to null)) map = map + ("y" to null) map += "y" to 1 assertEquals(mapOf("x" to null, "y" to 1), map) @@ -220,11 +220,11 @@ abstract class ImmutableMapTest { val map = immutableMapOf("x" to Value(1)) val newValue = Value(1) - val newMap = map.put("x", newValue) + val newMap = map.putting("x", newValue) assertNotSame(map, newMap) assertEquals(map, newMap) - val sameMap = newMap.put("x", newValue) + val sameMap = newMap.putting("x", newValue) assertSame(newMap, sameMap) } @@ -233,12 +233,12 @@ abstract class ImmutableMapTest { fun assertEquals(expected: Map, actual: Map) = kotlin.test.assertEquals(expected, actual) - assertEquals(mapOf("x" to 1), map.remove(null)) - assertEquals(mapOf("x" to 1), map.remove(null, "x")) - assertEquals(map, map.remove("x", 2)) + assertEquals(mapOf("x" to 1), map.removing(null)) + assertEquals(mapOf("x" to 1), map.removing(null, "x")) + assertEquals(map, map.removing("x", 2)) - assertEquals(emptyMap(), map.clear()) - assertEquals(emptyMap(), map.remove("x").remove(null)) + assertEquals(emptyMap(), map.cleared()) + assertEquals(emptyMap(), map.removing("x").removing(null)) } @Test @@ -291,7 +291,7 @@ abstract class ImmutableMapTest { } @Test fun noOperation() { - immutableMapOf().toPersistentMap().testNoOperation({ clear() }, { clear() }) + immutableMapOf().toPersistentMap().testNoOperation({ cleared() }, { clear() }) val key = ObjectWrapper("x", "x".hashCode()) val equalKey = ObjectWrapper("x", "x".hashCode()) // equalKey == key && equalKey !== key @@ -311,17 +311,17 @@ abstract class ImmutableMapTest { */ val map = immutableMapOf(key to value, null to "x").toPersistentMap() - map.testNoOperation({ remove(notEqualKey) }, { remove(notEqualKey) }) - map.testNotNoOperation({ remove(equalKey) }, { remove(equalKey) }) + map.testNoOperation({ removing(notEqualKey) }, { remove(notEqualKey) }) + map.testNotNoOperation({ removing(equalKey) }, { remove(equalKey) }) - map.testNoOperation({ remove(key, notEqualValue) }, { remove(key, notEqualValue) }) - map.testNotNoOperation({ remove(key, equalValue) }, { remove(key, equalValue) }) + map.testNoOperation({ removing(key, notEqualValue) }, { remove(key, notEqualValue) }) + map.testNotNoOperation({ removing(key, equalValue) }, { remove(key, equalValue) }) - map.testNoOperation({ put(equalKey, value) }, { put(equalKey, value) }) - map.testNotNoOperation({ put(equalKey, equalValue) }, { put(equalKey, equalValue) }) + map.testNoOperation({ putting(equalKey, value) }, { put(equalKey, value) }) + map.testNotNoOperation({ putting(equalKey, equalValue) }, { put(equalKey, equalValue) }) - map.testNoOperation({ putAll(this) }, { putAll(this) }) - map.testNoOperation({ putAll(emptyMap()) }, { putAll(emptyMap()) }) + map.testNoOperation({ puttingAll(this) }, { putAll(this) }) + map.testNoOperation({ puttingAll(emptyMap()) }, { putAll(emptyMap()) }) } fun PersistentMap.testNoOperation(persistent: PersistentMap.() -> PersistentMap, mutating: MutableMap.() -> Unit) { @@ -392,4 +392,4 @@ abstract class ImmutableMapTest { testEquality(data, changed) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/contract/map/KT41278Test.kt b/core/commonTest/src/contract/map/KT41278Test.kt index 47041b4d..937e2d03 100644 --- a/core/commonTest/src/contract/map/KT41278Test.kt +++ b/core/commonTest/src/contract/map/KT41278Test.kt @@ -42,7 +42,7 @@ class KT41278Test { @Test fun persistentOrderedMap() { val mapLetterToIndex = ('a'..'z').mapIndexed { i, c -> "$c" to i }.fold(persistentMapOf()) { map, pair -> - map.put(pair.first, pair.second) + map.putting(pair.first, pair.second) } doContainsTest(mapLetterToIndex, "h", 7, ::TestMapEntry) @@ -55,7 +55,7 @@ class KT41278Test { @Test fun persistentHashMap() { val mapLetterToIndex = ('a'..'z').mapIndexed { i, c -> "$c" to i }.fold(persistentHashMapOf()) { map, pair -> - map.put(pair.first, pair.second) + map.putting(pair.first, pair.second) } doContainsTest(mapLetterToIndex, "h", 7, ::TestMapEntry) diff --git a/core/commonTest/src/contract/map/PersistentHashMapTest.kt b/core/commonTest/src/contract/map/PersistentHashMapTest.kt index f7f43029..20db4299 100644 --- a/core/commonTest/src/contract/map/PersistentHashMapTest.kt +++ b/core/commonTest/src/contract/map/PersistentHashMapTest.kt @@ -25,7 +25,7 @@ class PersistentHashMapTest { assertEquals(map1, map2.toMap()) assertEquals(map1, map2) - val map3 = map1.remove(0) + val map3 = map1.removing(0) builder.remove(0) val map4 = builder.build() @@ -64,7 +64,7 @@ class PersistentHashMapTest { val original: PersistentHashMap = persistentHashMapOf(a to "a", b to "b", c to "c", d to "d") as PersistentHashMap - val afterImmutableRemoving = original.remove(b).remove(c) + val afterImmutableRemoving = original.removing(b).removing(c) val builder = original.builder() builder.remove(b) @@ -73,4 +73,4 @@ class PersistentHashMapTest { assertEquals(afterImmutableRemoving, afterMutableRemoving) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/contract/set/ImmutableSetTest.kt b/core/commonTest/src/contract/set/ImmutableSetTest.kt index 1339ebcf..72df0ba1 100644 --- a/core/commonTest/src/contract/set/ImmutableSetTest.kt +++ b/core/commonTest/src/contract/set/ImmutableSetTest.kt @@ -22,26 +22,26 @@ class ImmutableHashSetTest : ImmutableSetTestBase() { @Test fun addAllElements() { run { val left = immutableSetOf() + (1..2000) - assertSame(left, left.addAll(immutableSetOf())) - compareSets(left, immutableSetOf().addAll(left)) + assertSame(left, left.addingAll(immutableSetOf())) + compareSets(left, immutableSetOf().addingAll(left)) } run { val left = immutableSetOf() + (1..2000) val right = immutableSetOf() + (200..3000) - compareSets(left.toSet() + right.toSet(), left.addAll(right)) + compareSets(left.toSet() + right.toSet(), left.addingAll(right)) } run { val left = immutableSetOf() + (1..2000).map { IntWrapper(it, it % 200) } val right = immutableSetOf() + (200..3000).map { IntWrapper(it, it % 200) } - compareSets(left.toSet() + right.toSet(), left.addAll(right)) + compareSets(left.toSet() + right.toSet(), left.addingAll(right)) } run { val left = immutableSetOf() + (1..2000).map { "$it" } val right = immutableSetOf() + (200..3000).map { "$it" } - compareSets(left.toSet() + right.toSet(), left.addAll(right)) + compareSets(left.toSet() + right.toSet(), left.addingAll(right)) } run { @@ -87,8 +87,8 @@ class ImmutableHashSetTest : ImmutableSetTestBase() { @Test fun retainAllElements() { run { val left = immutableSetOf() + (1..2000) - compareSets(immutableSetOf(), left.retainAll(immutableSetOf())) - compareSets(immutableSetOf(), immutableSetOf().retainAll(left)) + compareSets(immutableSetOf(), left.retainingAll(immutableSetOf())) + compareSets(immutableSetOf(), immutableSetOf().retainingAll(left)) } run { @@ -141,8 +141,8 @@ class ImmutableHashSetTest : ImmutableSetTestBase() { @Test fun removeAllElements() { run { val left = immutableSetOf() + (1..2000) - assertSame(left, left.removeAll(immutableSetOf())) - assertSame(immutableSetOf(), immutableSetOf().removeAll(left)) + assertSame(left, left.removingAll(immutableSetOf())) + assertSame(immutableSetOf(), immutableSetOf().removingAll(left)) } run { @@ -267,14 +267,14 @@ abstract class ImmutableSetTestBase { hashSet.remove("a") assertNotEquals>(hashSet, immSet) - immSet = immSet.remove("a") + immSet = immSet.removing("a") compareSetsUnordered(hashSet, immSet) } @Test fun addElements() { var set = immutableSetOf() - set = set.add("x") - set = set.addAll(set) + set = set.adding("x") + set = set.addingAll(set) set = set + "y" set += "z" set += arrayOf("1", "2").asIterable() @@ -288,14 +288,14 @@ abstract class ImmutableSetTestBase { compareSets(content.toSet(), set) } - expectSet("abcyz12", set.remove('x')) + expectSet("abcyz12", set.removing('x')) expectSet("abcyz12", set - 'x') - expectSet("abcy12", set.removeAll(setOf('x', 'z'))) + expectSet("abcy12", set.removingAll(setOf('x', 'z'))) expectSet("abcy12", set - setOf('x', 'z')) - expectSet("abcxyz", set.removeAll { it.isDigit() }) + expectSet("abcxyz", set.removingAll { it.isDigit() }) compareSets(emptySet(), set - set) - compareSets(emptySet(), set.clear()) + compareSets(emptySet(), set.cleared()) } @Test fun builder() { @@ -334,17 +334,17 @@ abstract class ImmutableSetTestBase { } @Test open fun noOperation() { - immutableSetOf().testNoOperation({ clear() }, { clear() }) + immutableSetOf().testNoOperation({ cleared() }, { clear() }) val set = immutableSetOf("abcxyz12".toList()) with(set) { - testNoOperation({ add('a') }, { add('a') }) - testNoOperation({ addAll(emptySet()) }, { addAll(emptySet()) }) - testNoOperation({ addAll(listOf('a', 'b')) }, { addAll(listOf('a', 'b')) }) - testNoOperation({ remove('d') }, { remove('d') }) - testNoOperation({ removeAll(listOf('d', 'e')) }, { removeAll(listOf('d', 'e')) }) - testNoOperation({ removeAll { it.isUpperCase() } }, { removeAll { it.isUpperCase() } }) - testNoOperation({ removeAll(emptySet()) }, { removeAll(emptySet()) }) + testNoOperation({ adding('a') }, { add('a') }) + testNoOperation({ addingAll(emptySet()) }, { addAll(emptySet()) }) + testNoOperation({ addingAll(listOf('a', 'b')) }, { addAll(listOf('a', 'b')) }) + testNoOperation({ removing('d') }, { remove('d') }) + testNoOperation({ removingAll(listOf('d', 'e')) }, { removeAll(listOf('d', 'e')) }) + testNoOperation({ removingAll { it.isUpperCase() } }, { removeAll { it.isUpperCase() } }) + testNoOperation({ removingAll(emptySet()) }, { removeAll(emptySet()) }) } } @@ -404,4 +404,4 @@ abstract class ImmutableSetTestBase { testEquality(data, changed) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/contract/set/PersistentHashSetTest.kt b/core/commonTest/src/contract/set/PersistentHashSetTest.kt index ea86ff70..9c10d3ce 100644 --- a/core/commonTest/src/contract/set/PersistentHashSetTest.kt +++ b/core/commonTest/src/contract/set/PersistentHashSetTest.kt @@ -24,7 +24,7 @@ class PersistentHashSetTest { assertEquals(set1, builder.build()) assertEquals(set1, builder.build().toSet()) - val set2 = set1.remove(0) + val set2 = set1.removing(0) builder.remove(0) assertEquals(set2, builder.build().toSet()) @@ -56,4 +56,4 @@ class PersistentHashSetTest { assertEquals(expected, actual) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/contract/set/PersistentOrderedSetTest.kt b/core/commonTest/src/contract/set/PersistentOrderedSetTest.kt index a3d639d9..bc0614ff 100644 --- a/core/commonTest/src/contract/set/PersistentOrderedSetTest.kt +++ b/core/commonTest/src/contract/set/PersistentOrderedSetTest.kt @@ -24,10 +24,10 @@ class PersistentOrderedSetTest { assertEquals(set1, builder.build()) assertEquals(set1, builder.build().toSet()) - val set2 = set1.remove(0) + val set2 = set1.removing(0) builder.remove(0) assertEquals(set2, builder.build().toSet()) assertEquals(set2, builder.build()) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/implementations/map/HashMapTrieNodeTest.kt b/core/commonTest/src/implementations/map/HashMapTrieNodeTest.kt index 822d3707..79571bec 100644 --- a/core/commonTest/src/implementations/map/HashMapTrieNodeTest.kt +++ b/core/commonTest/src/implementations/map/HashMapTrieNodeTest.kt @@ -30,7 +30,7 @@ class HashMapTrieNodeTest { testEmptyMap(map) val wrapper1 = IntWrapper(1, 0b100_01101) - map = map.put(wrapper1, 1) + map = map.putting(wrapper1, 1) map.node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> assertEquals(0, shift) @@ -40,7 +40,7 @@ class HashMapTrieNodeTest { assertTrue(arrayOf(wrapper1, 1) contentEquals node.buffer) } - map = map.remove(wrapper1) + map = map.removing(wrapper1) testEmptyMap(map) } @@ -59,7 +59,7 @@ class HashMapTrieNodeTest { fun canonicalization() { val wrapper1 = IntWrapper(1, 0b1) val wrapper33 = IntWrapper(33, 0b1_00001) - val map = PersistentHashMap.emptyOf().put(wrapper1, 1).put(wrapper33, 33) + val map = PersistentHashMap.emptyOf().putting(wrapper1, 1).putting(wrapper33, 33) map.node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> if (shift == 0) { @@ -74,7 +74,7 @@ class HashMapTrieNodeTest { } } - map.remove(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> + map.removing(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> assertEquals(0, shift) assertEquals(0, hash) assertEquals(0b10, dataMap) @@ -82,7 +82,7 @@ class HashMapTrieNodeTest { assertTrue(arrayOf(wrapper33, 33) contentEquals node.buffer) } - testEmptyMap(map.remove(wrapper1).remove(wrapper33)) + testEmptyMap(map.removing(wrapper1).removing(wrapper33)) } // Remove (1057, 1057) @@ -104,7 +104,7 @@ class HashMapTrieNodeTest { val wrapper1 = IntWrapper(1, 0b1) val wrapper33 = IntWrapper(33, 0b1_00001) val wrapper1057 = IntWrapper(1057, 0b1_00001_00001) - val map = PersistentHashMap.emptyOf().put(wrapper1, 1).put(wrapper33, 33).put(wrapper1057, 1057) + val map = PersistentHashMap.emptyOf().putting(wrapper1, 1).putting(wrapper33, 33).putting(wrapper1057, 1057) map.node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> when (shift) { @@ -128,7 +128,7 @@ class HashMapTrieNodeTest { } } - map.remove(wrapper1057).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> + map.removing(wrapper1057).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> if (shift == 0) { assertEquals(0b0, dataMap) assertEquals(0b10, nodeMap) @@ -161,9 +161,9 @@ class HashMapTrieNodeTest { val wrapper1 = IntWrapper(1, 0b1) val wrapper33 = IntWrapper(33, 0b1_00001) val wrapper1057 = IntWrapper(1057, 0b1_00001_00001) - val map = PersistentHashMap.emptyOf().put(wrapper1, 1).put(wrapper33, 33).put(wrapper1057, 1057) + val map = PersistentHashMap.emptyOf().putting(wrapper1, 1).putting(wrapper33, 33).putting(wrapper1057, 1057) - map.remove(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> + map.removing(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> when (shift) { 0 -> { assertEquals(0b0, dataMap) @@ -184,7 +184,7 @@ class HashMapTrieNodeTest { } } - map.remove(wrapper1).remove(wrapper1057).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> + map.removing(wrapper1).removing(wrapper1057).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> assertEquals(0, shift) assertEquals(0, hash) assertEquals(0b10, dataMap) @@ -192,7 +192,7 @@ class HashMapTrieNodeTest { assertTrue(arrayOf(wrapper33, 33) contentEquals node.buffer) } - testEmptyMap(map.remove(wrapper1).remove(wrapper1057).remove(wrapper33)) + testEmptyMap(map.removing(wrapper1).removing(wrapper1057).removing(wrapper33)) } // Nodes drawn using square braces are collision nodes. @@ -215,7 +215,7 @@ class HashMapTrieNodeTest { fun collision() { val wrapper1 = IntWrapper(1, 0b1) val wrapper2 = IntWrapper(2, 0b1) - val map = PersistentHashMap.emptyOf().put(wrapper1, 1).put(wrapper2, 2) + val map = PersistentHashMap.emptyOf().putting(wrapper1, 1).putting(wrapper2, 2) map.node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> if (shift > MAX_SHIFT) { @@ -230,7 +230,7 @@ class HashMapTrieNodeTest { } } - map.remove(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> + map.removing(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> assertEquals(0, shift) assertEquals(0, hash) assertEquals(0b10, dataMap) @@ -238,7 +238,7 @@ class HashMapTrieNodeTest { assertTrue(arrayOf(wrapper2, 2) contentEquals node.buffer) } - testEmptyMap(map.remove(wrapper1).remove(wrapper2)) + testEmptyMap(map.removing(wrapper1).removing(wrapper2)) } // Nodes drawn using square braces are collision nodes. @@ -266,7 +266,7 @@ class HashMapTrieNodeTest { val wrapper1 = IntWrapper(1, 0b1) val wrapper2 = IntWrapper(2, 0b1) val wrapper3 = IntWrapper(3, 0b1_00001) - val map = PersistentHashMap.emptyOf().put(wrapper1, 1).put(wrapper2, 2).put(wrapper3, 3) + val map = PersistentHashMap.emptyOf().putting(wrapper1, 1).putting(wrapper2, 2).putting(wrapper3, 3) map.node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> when (shift) { @@ -295,7 +295,7 @@ class HashMapTrieNodeTest { } } - map.remove(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> + map.removing(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> if (shift == 0) { assertEquals(0b0, dataMap) assertEquals(0b10, nodeMap) @@ -334,9 +334,9 @@ class HashMapTrieNodeTest { val wrapper1 = IntWrapper(1, 0b1) val wrapper2 = IntWrapper(2, 0b1) val wrapper3 = IntWrapper(3, 0b1_00001) - val map = PersistentHashMap.emptyOf().put(wrapper1, 1).put(wrapper2, 2).put(wrapper3, 3) + val map = PersistentHashMap.emptyOf().putting(wrapper1, 1).putting(wrapper2, 2).putting(wrapper3, 3) - map.remove(wrapper3).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> + map.removing(wrapper3).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> when (shift) { in 0..MAX_SHIFT -> { val code = if (shift == 0) 0 else 1 @@ -354,7 +354,7 @@ class HashMapTrieNodeTest { } } - map.remove(wrapper3).remove(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> + map.removing(wrapper3).removing(wrapper1).node.accept { node: TrieNode, shift: Int, hash: Int, dataMap: Int, nodeMap: Int -> assertEquals(0, shift) assertEquals(0, hash) assertEquals(0b10, dataMap) @@ -448,4 +448,4 @@ class HashMapTrieNodeTest { } } */ -} \ No newline at end of file +} diff --git a/core/commonTest/src/stress/list/PersistentListBuilderTest.kt b/core/commonTest/src/stress/list/PersistentListBuilderTest.kt index ec587c94..5a40d27d 100644 --- a/core/commonTest/src/stress/list/PersistentListBuilderTest.kt +++ b/core/commonTest/src/stress/list/PersistentListBuilderTest.kt @@ -308,7 +308,7 @@ class PersistentListBuilderTest : ExecutionTimeMeasuringTest() { private fun PersistentList(size: Int, producer: (Int) -> E): PersistentList { var list = persistentListOf() repeat(times = size) { index -> - list = list.add(producer(index)) + list = list.adding(producer(index)) } return list } @@ -491,7 +491,7 @@ class PersistentListBuilderTest : ExecutionTimeMeasuringTest() { for (initialSize in listSizes) { val initialElements = List(initialSize) { it } - val list = initialElements.fold(persistentListOf()) { list, element -> list.add(element) } + val list = initialElements.fold(persistentListOf()) { list, element -> list.adding(element) } val addIndex = mutableListOf( initialSize // append @@ -535,7 +535,7 @@ class PersistentListBuilderTest : ExecutionTimeMeasuringTest() { for (initialSize in listSizes) { val initialElements = List(initialSize) { it } - val list = initialElements.fold(persistentListOf()) { list, element -> list.add(element) } + val list = initialElements.fold(persistentListOf()) { list, element -> list.adding(element) } val removeElements = mutableListOf( initialElements // all @@ -653,4 +653,4 @@ class PersistentListBuilderTest : ExecutionTimeMeasuringTest() { // assertEquals(list1, list2) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/stress/list/PersistentListTest.kt b/core/commonTest/src/stress/list/PersistentListTest.kt index fa17d416..6d0f56cd 100644 --- a/core/commonTest/src/stress/list/PersistentListTest.kt +++ b/core/commonTest/src/stress/list/PersistentListTest.kt @@ -20,20 +20,20 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertTrue(vector.isEmpty()) - assertFalse(vector.add("last").isEmpty()) + assertFalse(vector.adding("last").isEmpty()) val elementsToAdd = NForAlgorithmComplexity.O_N val elements = distinctStringValues(elementsToAdd) repeat(times = elementsToAdd) { index -> - vector = vector.add(elements[index]) + vector = vector.adding(elements[index]) assertFalse(vector.isEmpty()) } repeat(times = elementsToAdd - 1) { - vector = vector.removeAt(vector.size - 1) + vector = vector.removingAt(vector.size - 1) assertFalse(vector.isEmpty()) } - vector = vector.removeAt(vector.size - 1) + vector = vector.removingAt(vector.size - 1) assertTrue(vector.isEmpty()) } @@ -42,16 +42,16 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertTrue(vector.size == 0) - assertEquals(1, vector.add(1).size) + assertEquals(1, vector.adding(1).size) val elementsToAdd = NForAlgorithmComplexity.O_N repeat(times = elementsToAdd) { index -> - vector = vector.add(index) + vector = vector.adding(index) assertEquals(index + 1, vector.size) } repeat(times = elementsToAdd) { index -> - vector = vector.removeAt(vector.size - 1) + vector = vector.removingAt(vector.size - 1) assertEquals(elementsToAdd - index - 1, vector.size) } } @@ -62,18 +62,18 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertNull(vector.firstOrNull()) - assertEquals(1, vector.add(0, 1).first()) - assertEquals(1, vector.add(1).first()) + assertEquals(1, vector.adding(0, 1).first()) + assertEquals(1, vector.adding(1).first()) val elementsToAdd = NForAlgorithmComplexity.O_NN repeat(times = elementsToAdd) { index -> - vector = vector.add(0, index) + vector = vector.adding(0, index) assertEquals(index, vector.first()) } repeat(times = elementsToAdd) { index -> assertEquals(elementsToAdd - index - 1, vector.first()) - vector = vector.removeAt(0) + vector = vector.removingAt(0) } assertNull(vector.firstOrNull()) } @@ -83,18 +83,18 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertNull(vector.lastOrNull()) - assertEquals(1, vector.add(0, 1).last()) - assertEquals(1, vector.add(1).last()) + assertEquals(1, vector.adding(0, 1).last()) + assertEquals(1, vector.adding(1).last()) val elementsToAdd = NForAlgorithmComplexity.O_N repeat(times = elementsToAdd) { index -> - vector = vector.add(index) + vector = vector.adding(index) assertEquals(index, vector.last()) } repeat(times = elementsToAdd) { index -> assertEquals(elementsToAdd - index - 1, vector.last()) - vector = vector.removeAt(vector.size - 1) + vector = vector.removingAt(vector.size - 1) } assertNull(vector.lastOrNull()) } @@ -104,23 +104,23 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertEquals(emptyList(), vector.toList()) - assertEquals(listOf(1), vector.add(1).toList()) + assertEquals(listOf(1), vector.adding(1).toList()) assertEquals( listOf(1, 2, 3, 4, 5, 6), vector - .add(1).add(2).add(3).add(4).add(5) - .add(6) + .adding(1).adding(2).adding(3).adding(4).adding(5) + .adding(6) .toList() ) assertEquals( listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20), vector - .add(1).add(2).add(3).add(4).add(5) - .add(6).add(7).add(8).add(9).add(10) - .add(11).add(12).add(13).add(14).add(15) - .add(16).add(17).add(18).add(19).add(20) + .adding(1).adding(2).adding(3).adding(4).adding(5) + .adding(6).adding(7).adding(8).adding(9).adding(10) + .adding(11).adding(12).adding(13).adding(14).adding(15) + .adding(16).adding(17).adding(18).adding(19).adding(20) .toList() ) @@ -129,7 +129,7 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { val list = mutableListOf() repeat(times = elementsToAdd) { index -> list.add(index) - vector = vector.add(index) + vector = vector.adding(index) assertEquals(list, vector.toList()) } } @@ -140,14 +140,14 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertNull(vector.firstOrNull()) - assertEquals(1, vector.add(0, 1).first()) - assertEquals(1, vector.add(0, 1).last()) + assertEquals(1, vector.adding(0, 1).first()) + assertEquals(1, vector.adding(0, 1).last()) val elementsToAdd = NForAlgorithmComplexity.O_NN val allElements = List(elementsToAdd) { elementsToAdd - it - 1 } repeat(times = elementsToAdd) { index -> - vector = vector.add(0, index) + vector = vector.adding(0, index) assertEquals(index, vector.first()) assertEquals(0, vector.last()) @@ -162,13 +162,13 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { fun addLastTests() { var vector = persistentListOf() - assertEquals(1, vector.add(1)[0]) + assertEquals(1, vector.adding(1)[0]) val elementsToAdd = NForAlgorithmComplexity.O_NN val allElements = List(elementsToAdd) { it } repeat(times = elementsToAdd) { index -> - vector = vector.add(index) + vector = vector.adding(index) assertEquals(0, vector[0]) assertEquals(index, vector[index]) @@ -184,16 +184,16 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertFailsWith { - vector.removeAt(0) + vector.removingAt(0) } - assertTrue(vector.add(1).removeAt(0).isEmpty()) - assertTrue(vector.add(0, 1).removeAt(0).isEmpty()) + assertTrue(vector.adding(1).removingAt(0).isEmpty()) + assertTrue(vector.adding(0, 1).removingAt(0).isEmpty()) val elementsToAdd = NForAlgorithmComplexity.O_NN val allElements = List(elementsToAdd) { it } repeat(times = elementsToAdd) { index -> - vector = vector.add(index) + vector = vector.adding(index) } repeat(times = elementsToAdd) { index -> assertEquals(elementsToAdd - 1, vector.last()) @@ -201,7 +201,7 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { assertEquals(elementsToAdd - index, vector.size) assertEquals(allElements.subList(index, elementsToAdd), vector) - vector = vector.removeAt(0) + vector = vector.removingAt(0) } } @@ -210,16 +210,16 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertFailsWith { - vector.removeAt(vector.size - 1) + vector.removingAt(vector.size - 1) } - assertTrue(vector.add(1).removeAt(0).isEmpty()) - assertTrue(vector.add(0, 1).removeAt(0).isEmpty()) + assertTrue(vector.adding(1).removingAt(0).isEmpty()) + assertTrue(vector.adding(0, 1).removingAt(0).isEmpty()) val elementsToAdd = NForAlgorithmComplexity.O_NN val allElements = List(elementsToAdd) { elementsToAdd - it - 1 } repeat(times = elementsToAdd) { index -> - vector = vector.add(0, index) + vector = vector.adding(0, index) } repeat(times = elementsToAdd) { index -> assertEquals(index, vector.last()) @@ -227,20 +227,20 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { assertEquals(elementsToAdd - index, vector.size) assertEquals(allElements.subList(0, vector.size), vector) - vector = vector.removeAt(vector.size - 1) + vector = vector.removingAt(vector.size - 1) } val linear = NForAlgorithmComplexity.O_N repeat(times = linear) { index -> - vector = vector.add(index) + vector = vector.adding(index) } repeat(times = linear) { index -> assertEquals(linear - 1 - index, vector.last()) assertEquals(0, vector.first()) assertEquals(linear - index, vector.size) - vector = vector.removeAt(vector.size - 1) + vector = vector.removingAt(vector.size - 1) } } @@ -251,12 +251,12 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { assertFailsWith { vector[0] } - assertEquals(1, vector.add(1)[0]) + assertEquals(1, vector.adding(1)[0]) val elementsToAdd = NForAlgorithmComplexity.O_NNlogN repeat(times = elementsToAdd) { index -> - vector = vector.add(index) + vector = vector.adding(index) for (i in 0..index) { assertEquals(i, vector[i]) @@ -267,7 +267,7 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { assertEquals(i, vector[i - index]) } - vector = vector.removeAt(0) + vector = vector.removingAt(0) } } @@ -276,18 +276,18 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { var vector = persistentListOf() assertFailsWith { - vector.set(0, 0) + vector.replacingAt(0, 0) } - assertEquals(2, vector.add(1).set(0, 2)[0]) + assertEquals(2, vector.adding(1).replacingAt(0, 2)[0]) val elementsToAdd = NForAlgorithmComplexity.O_NNlogN repeat(times = elementsToAdd) { index -> - vector = vector.add(index * 2) + vector = vector.adding(index * 2) for (i in 0..index) { assertEquals(i + index, vector[i]) - vector = vector.set(i, i + index + 1) + vector = vector.replacingAt(i, i + index + 1) assertEquals(i + index + 1, vector[i]) } } @@ -296,11 +296,11 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { val expected = elementsToAdd + i assertEquals(expected, vector[i]) - vector = vector.set(i, expected - 1) + vector = vector.replacingAt(i, expected - 1) assertEquals(expected - 1, vector[i]) } - vector = vector.removeAt(0) + vector = vector.removingAt(0) } } @@ -315,7 +315,7 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { for (initialSize in listSizes) { val initialElements = List(initialSize) { it } - val list = initialElements.fold(persistentListOf()) { list, element -> list.add(element) } + val list = initialElements.fold(persistentListOf()) { list, element -> list.adding(element) } val addIndex = mutableListOf( initialSize // append @@ -339,7 +339,7 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { for (size in addSize..(addSize + maxBufferSize)) { val elementsToAdd = List(size) { initialSize + it } - val result = list.addAll(index, elementsToAdd) + val result = list.addingAll(index, elementsToAdd) val expected = initialElements.toMutableList().also { it.addAll(index, elementsToAdd) } assertEquals>(expected, result) @@ -359,7 +359,7 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { for (initialSize in listSizes) { val initialElements = List(initialSize) { it } - val list = initialElements.fold(persistentListOf()) { list, element -> list.add(element) } + val list = initialElements.fold(persistentListOf()) { list, element -> list.adding(element) } val removeElements = mutableListOf( initialElements // all @@ -391,11 +391,11 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { // println("${initialElements.size} -> ${expected.size} : ${initialElements.size.toDouble() / expected.size}") - val result = list.removeAll(elements) + val result = list.removingAll(elements) val resultPredicate = list.let { val hashSet = elements.toHashSet() - it.removeAll { e -> hashSet.contains(e) } + it.removingAll { e -> hashSet.contains(e) } } assertEquals>(expected, result) @@ -426,15 +426,15 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { val newVector = if (list.isNotEmpty() && shouldRemove) { list.removeAt(operationIndex) - vector.removeAt(operationIndex) + vector.removingAt(operationIndex) } else if (list.isNotEmpty() && shouldSet) { val value = Random.nextInt() list[operationIndex] = value - vector.set(operationIndex, value) + vector.replacingAt(operationIndex, value) } else { val value = Random.nextInt() list.add(operationIndex, value) - vector.add(operationIndex, value) + vector.adding(operationIndex, value) } testAfterOperation(list, newVector, operationIndex) @@ -453,7 +453,7 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { while (list.isNotEmpty()) { val removeIndex = Random.nextInt(list.size) list.removeAt(removeIndex) - vector = vector.removeAt(removeIndex) + vector = vector.removingAt(removeIndex) testAfterOperation(list, vector, removeIndex) } @@ -477,4 +477,4 @@ class PersistentListTest : ExecutionTimeMeasuringTest() { // assertEquals(list, vector) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/stress/map/PersistentHashMapBuilderTest.kt b/core/commonTest/src/stress/map/PersistentHashMapBuilderTest.kt index 4f51852a..78768b86 100644 --- a/core/commonTest/src/stress/map/PersistentHashMapBuilderTest.kt +++ b/core/commonTest/src/stress/map/PersistentHashMapBuilderTest.kt @@ -119,7 +119,7 @@ class PersistentHashMapBuilderTest : ExecutionTimeMeasuringTest() { val key = IntWrapper(keyValue, keyHash) expected[key] = keyValue - map = map.put(key, keyValue) + map = map.putting(key, keyValue) val shouldTest = Random.nextDouble() < 0.1 if (shouldTest) { @@ -270,7 +270,7 @@ class PersistentHashMapBuilderTest : ExecutionTimeMeasuringTest() { val elementsToRemoveFromMap = expectedKeys.size / 2 expectedKeys.take(elementsToRemoveFromMap).forEach { key -> expectedKeys.remove(key) - map = map.remove(key) + map = map.removing(key) } assertEquals>(expectedKeys, map.keys) @@ -279,13 +279,13 @@ class PersistentHashMapBuilderTest : ExecutionTimeMeasuringTest() { val keyValue = Random.nextInt() val key = keyGen.wrapper(keyValue) expectedKeys.add(key) - map = map.put(key, keyValue) + map = map.putting(key, keyValue) } assertEquals>(expectedKeys, map.keys) expectedKeys.toHashSet().forEach { key -> expectedKeys.remove(key) - map = map.remove(key) + map = map.removing(key) } assertEquals>(expectedKeys, map.keys) } @@ -509,4 +509,4 @@ class PersistentHashMapBuilderTest : ExecutionTimeMeasuringTest() { // assertEquals(expected.keys, actual.keys) // assertEquals(expected.values.sorted(), actual.values.sorted()) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/stress/map/PersistentHashMapTest.kt b/core/commonTest/src/stress/map/PersistentHashMapTest.kt index dbd9772d..b052856b 100644 --- a/core/commonTest/src/stress/map/PersistentHashMapTest.kt +++ b/core/commonTest/src/stress/map/PersistentHashMapTest.kt @@ -23,20 +23,20 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { var map = persistentHashMapOf() assertTrue(map.isEmpty()) - assertFalse(map.put(0, "last").isEmpty()) + assertFalse(map.putting(0, "last").isEmpty()) val elementsToAdd = NForAlgorithmComplexity.O_NlogN val values = distinctStringValues(elementsToAdd) repeat(times = elementsToAdd) { index -> - map = map.put(index, values[index]) + map = map.putting(index, values[index]) assertFalse(map.isEmpty()) } repeat(times = elementsToAdd - 1) { index -> - map = map.remove(index) + map = map.removing(index) assertFalse(map.isEmpty()) } - map = map.remove(elementsToAdd - 1) + map = map.removing(elementsToAdd - 1) assertTrue(map.isEmpty()) } @@ -45,25 +45,25 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { var map = persistentHashMapOf() assertTrue(map.size == 0) - assertEquals(1, map.put(1, 1).size) + assertEquals(1, map.putting(1, 1).size) val elementsToAdd = NForAlgorithmComplexity.O_NlogN repeat(times = elementsToAdd) { index -> - map = map.put(index, index) + map = map.putting(index, index) assertEquals(index + 1, map.size) - map = map.put(index, index) + map = map.putting(index, index) assertEquals(index + 1, map.size) - map = map.put(index, 7) + map = map.putting(index, 7) assertEquals(index + 1, map.size) } repeat(times = elementsToAdd) { index -> - map = map.remove(index) + map = map.removing(index) assertEquals(elementsToAdd - index - 1, map.size) - map = map.remove(index) + map = map.removing(index) assertEquals(elementsToAdd - index - 1, map.size) } } @@ -96,14 +96,14 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { repeat(times = elementsToAdd) { val key = Random.nextInt() set.add(key) - map = map.put(key, key) + map = map.putting(key, key) testProperties(set, map) } set.toMutableSet().forEach { key -> set.remove(key) - map = map.remove(key) + map = map.removing(key) testProperties(set, map) } @@ -112,18 +112,18 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { @Test fun removeTests() { var map = persistentHashMapOf() - assertTrue(map.put(0, "0").remove(0).isEmpty()) + assertTrue(map.putting(0, "0").removing(0).isEmpty()) val elementsToAdd = NForAlgorithmComplexity.O_NlogN val values = distinctStringValues(elementsToAdd) repeat(times = elementsToAdd) { index -> - map = map.put(index, values[index]) + map = map.putting(index, values[index]) } repeat(times = elementsToAdd) { index -> assertEquals(elementsToAdd - index, map.size) assertEquals(values[index], map[index]) - map = map.remove(index) + map = map.removing(index) assertNull(map[index]) } assertTrue(map.isEmpty()) @@ -132,21 +132,21 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { @Test fun removeEntryTests() { var map = persistentHashMapOf() - assertTrue(map.put(0, "0").remove(0, "0").isEmpty()) - assertFalse(map.put(0, "0").remove(0, "x").isEmpty()) + assertTrue(map.putting(0, "0").removing(0, "0").isEmpty()) + assertFalse(map.putting(0, "0").removing(0, "x").isEmpty()) val elementsToAdd = NForAlgorithmComplexity.O_NlogN val values = distinctStringValues(elementsToAdd + 1) repeat(times = elementsToAdd) { index -> - map = map.put(index, values[index]) + map = map.putting(index, values[index]) } repeat(times = elementsToAdd) { index -> assertEquals(elementsToAdd - index, map.size) assertEquals(values[index], map[index]) - map = map.remove(index, values[index + 1]) + map = map.removing(index, values[index + 1]) assertEquals(values[index], map[index]) - map = map.remove(index, values[index]) + map = map.removing(index, values[index]) assertNull(map[index]) } assertTrue(map.isEmpty()) @@ -155,13 +155,13 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { @Test fun getTests() { var map = persistentHashMapOf() - assertEquals("1", map.put(1, "1")[1]) + assertEquals("1", map.putting(1, "1")[1]) val elementsToAdd = NForAlgorithmComplexity.O_NNlogN val values = distinctStringValues(elementsToAdd) repeat(times = elementsToAdd) { index -> - map = map.put(index, values[index]) + map = map.putting(index, values[index]) for (i in 0..index) { assertEquals(values[i], map[i]) @@ -172,26 +172,26 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { assertEquals(values[i], map[i]) } - map = map.remove(index) + map = map.removing(index) } } @Test fun putTests() { var map = persistentHashMapOf() - assertEquals("2", map.put(1, "1").put(1, "2")[1]) + assertEquals("2", map.putting(1, "1").putting(1, "2")[1]) val elementsToAdd = NForAlgorithmComplexity.O_NNlogN val values = distinctStringValues(2 * elementsToAdd) repeat(times = elementsToAdd) { index -> - map = map.put(index, values[2 * index]) + map = map.putting(index, values[2 * index]) for (i in 0..index) { val valueIndex = i + index assertEquals(values[valueIndex], map[i]) - map = map.put(i, values[valueIndex + 1]) + map = map.putting(i, values[valueIndex + 1]) assertEquals(values[valueIndex + 1], map[i]) } } @@ -200,11 +200,11 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { val valueIndex = elementsToAdd - index + i assertEquals(values[valueIndex], map[i]) - map = map.put(i, values[valueIndex - 1]) + map = map.putting(i, values[valueIndex - 1]) assertEquals(values[valueIndex - 1], map[i]) } - map = map.remove(index) + map = map.removing(index) } assertTrue(map.isEmpty()) } @@ -215,8 +215,8 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { val oneWrapper = IntWrapper(1, 1) val twoWrapper = IntWrapper(2, 1) - assertEquals(1, map.put(oneWrapper, 1).put(twoWrapper, 2)[oneWrapper]) - assertEquals(2, map.put(oneWrapper, 1).put(twoWrapper, 2)[twoWrapper]) + assertEquals(1, map.putting(oneWrapper, 1).putting(twoWrapper, 2)[oneWrapper]) + assertEquals(2, map.putting(oneWrapper, 1).putting(twoWrapper, 2)[twoWrapper]) repeat(times = 2) { removeEntryPredicate -> @@ -229,11 +229,11 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { } repeat(times = elementsToAdd) { index -> - map = map.put(key(index), Int.MIN_VALUE) + map = map.putting(key(index), Int.MIN_VALUE) assertEquals(Int.MIN_VALUE, map[key(index)]) assertEquals(index + 1, map.size) - map = map.put(key(index), index) + map = map.putting(key(index), index) assertEquals(index + 1, map.size) val collisions = keyGen.wrappersByHashCode(key(index).hashCode) @@ -257,18 +257,18 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { map = if (removeEntryPredicate == 1) { val nonExistingValue = Int.MIN_VALUE - val sameMap = map.remove(key, nonExistingValue) + val sameMap = map.removing(key, nonExistingValue) assertEquals(map.size, sameMap.size) assertEquals(key.obj, sameMap[key]) - map.remove(key, key.obj) + map.removing(key, key.obj) } else { val nonExistingKey = IntWrapper(Int.MIN_VALUE, key.hashCode) - val sameMap = map.remove(nonExistingKey) + val sameMap = map.removing(nonExistingKey) assertEquals(map.size, sameMap.size) assertEquals(key.obj, sameMap[key]) - map.remove(key) + map.removing(key) } assertNull(map[key]) @@ -311,19 +311,19 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { val newImmutableMap = when { shouldRemoveByKey -> { mutableMap.remove(key) - immutableMap.remove(key) + immutableMap.removing(key) } shouldRemoveByKeyAndValue -> { val shouldBeCurrentValue = Random.nextDouble() < 0.8 val value = if (shouldOperateOnExistingKey && shouldBeCurrentValue) mutableMap[key] else Random.nextInt() mutableMap.remove(key, value) - immutableMap.remove(key, value) + immutableMap.removing(key, value) } else -> { val shouldPutNullValue = Random.nextDouble() < 0.001 val value = if (shouldPutNullValue) null else Random.nextInt() mutableMap[key] = value - immutableMap.put(key, value) + immutableMap.putting(key, value) } } @@ -343,7 +343,7 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { val keys = mutableMap.keys.toMutableList() for (key in keys) { mutableMap.remove(key) - immutableMap = immutableMap.remove(key) + immutableMap = immutableMap.removing(key) testAfterOperation(mutableMap, immutableMap, key) } @@ -364,4 +364,4 @@ class PersistentHashMapTest : ExecutionTimeMeasuringTest() { // assertEquals(expected.keys, actual.keys) // assertEquals(expected.values.sortedBy { it }, actual.values.sortedBy { it }) } -} \ No newline at end of file +} diff --git a/core/commonTest/src/stress/set/PersistentHashSetTest.kt b/core/commonTest/src/stress/set/PersistentHashSetTest.kt index 8fa14126..d0d84367 100644 --- a/core/commonTest/src/stress/set/PersistentHashSetTest.kt +++ b/core/commonTest/src/stress/set/PersistentHashSetTest.kt @@ -24,19 +24,19 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { var set = persistentHashSetOf() assertTrue(set.isEmpty()) - assertFalse(set.add(0).isEmpty()) + assertFalse(set.adding(0).isEmpty()) val elementsToAdd = NForAlgorithmComplexity.O_NlogN repeat(times = elementsToAdd) { index -> - set = set.add(index) + set = set.adding(index) assertFalse(set.isEmpty()) } repeat(times = elementsToAdd - 1) { index -> - set = set.remove(index) + set = set.removing(index) assertFalse(set.isEmpty()) } - set = set.remove(elementsToAdd - 1) + set = set.removing(elementsToAdd - 1) assertTrue(set.isEmpty()) } @@ -45,22 +45,22 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { var set = persistentHashSetOf() assertTrue(set.size == 0) - assertEquals(1, set.add(1).size) + assertEquals(1, set.adding(1).size) val elementsToAdd = NForAlgorithmComplexity.O_NlogN repeat(times = elementsToAdd) { index -> - set = set.add(index) + set = set.adding(index) assertEquals(index + 1, set.size) - set = set.add(index) + set = set.adding(index) assertEquals(index + 1, set.size) } repeat(times = elementsToAdd) { index -> - set = set.remove(index) + set = set.removing(index) assertEquals(elementsToAdd - index - 1, set.size) - set = set.remove(index) + set = set.removing(index) assertEquals(elementsToAdd - index - 1, set.size) } } @@ -76,14 +76,14 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { repeat(times = elementsToAdd) { val element = Random.nextInt() mutableSet.add(element) - set = set.add(element) + set = set.adding(element) assertEquals>(set, mutableSet) } mutableSet.toMutableList().forEach { element -> mutableSet.remove(element) - set = set.remove(element) + set = set.removing(element) assertEquals>(set, mutableSet) } @@ -94,18 +94,18 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { @Test fun removeTests() { var set = persistentHashSetOf() - assertTrue(set.add(0).remove(0).isEmpty()) + assertTrue(set.adding(0).removing(0).isEmpty()) val elementsToAdd = NForAlgorithmComplexity.O_NlogN repeat(times = elementsToAdd) { index -> - set = set.add(index) + set = set.adding(index) } repeat(times = elementsToAdd) { index -> assertEquals(elementsToAdd - index, set.size) assertTrue(set.contains(index)) - set = set.remove(index) + set = set.removing(index) assertFalse(set.contains(index)) } assertTrue(set.isEmpty()) @@ -114,13 +114,13 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { @Test fun containsTests() { var set = persistentHashSetOf() - assertTrue(set.add("1").contains("1")) + assertTrue(set.adding("1").contains("1")) val elementsToAdd = NForAlgorithmComplexity.O_NNlogN val elements = distinctStringValues(elementsToAdd) repeat(times = elementsToAdd) { index -> - set = set.add(elements[index]) + set = set.adding(elements[index]) for (i in 0..index) { assertTrue(set.contains(elements[i])) @@ -131,28 +131,28 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { assertTrue(set.contains(elements[i])) } - set = set.remove(elements[index]) + set = set.removing(elements[index]) } } @Test fun addTests() { var set = persistentHashSetOf() - assertTrue(set.add(1).add(1).contains(1)) + assertTrue(set.adding(1).adding(1).contains(1)) val elementsToAdd = NForAlgorithmComplexity.O_NNlogN repeat(times = elementsToAdd) { index -> - set = set.add(index * 2) + set = set.adding(index * 2) for (i in index downTo 0) { val element = i + index assertTrue(set.contains(element)) - set = set.remove(element) + set = set.removing(element) assertFalse(set.contains(element)) assertFalse(set.contains(element + 1)) - set = set.add(element + 1) + set = set.adding(element + 1) assertTrue(set.contains(element + 1)) } } @@ -161,14 +161,14 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { val element = elementsToAdd - index + i assertTrue(set.contains(element)) - set = set.remove(element) + set = set.removing(element) assertFalse(set.contains(element)) assertFalse(set.contains(element - 1)) - set = set.add(element - 1) + set = set.adding(element - 1) assertTrue(set.contains(element - 1)) } - set = set.remove(elementsToAdd - 1) + set = set.removing(elementsToAdd - 1) } assertTrue(set.isEmpty()) } @@ -177,7 +177,7 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { fun collisionTests() { var set = persistentHashSetOf() - assertTrue(set.add(IntWrapper(1, 1)).contains(IntWrapper(1, 1))) + assertTrue(set.adding(IntWrapper(1, 1)).contains(IntWrapper(1, 1))) val elementsToAdd = NForAlgorithmComplexity.O_NlogN @@ -188,11 +188,11 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { } repeat(times = elementsToAdd) { index -> - set = set.add(wrapper(index)) + set = set.adding(wrapper(index)) assertTrue(set.contains(wrapper(index))) assertEquals(index + 1, set.size) - set = set.add(wrapper(index)) + set = set.adding(wrapper(index)) assertEquals(index + 1, set.size) val collisions = eGen.wrappersByHashCode(wrapper(index).hashCode) @@ -215,11 +215,11 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { assertTrue(set.contains(wrapper)) val nonExistingElement = IntWrapper(wrapper.obj.inv(), wrapper.hashCode) - val sameSet = set.remove(nonExistingElement) + val sameSet = set.removing(nonExistingElement) assertEquals(set.size, sameSet.size) assertTrue(sameSet.contains(wrapper)) - set = set.remove(wrapper) + set = set.removing(wrapper) assertFalse(set.contains(wrapper)) } } @@ -256,11 +256,11 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { val newImmutableSet = when { shouldRemove -> { mutableSet.remove(element) - immutableSet.remove(element) + immutableSet.removing(element) } else -> { mutableSet.add(element) - immutableSet.add(element) + immutableSet.adding(element) } } @@ -280,7 +280,7 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { val elements = mutableSet.toMutableList() for (element in elements) { mutableSet.remove(element) - immutableSet = immutableSet.remove(element) + immutableSet = immutableSet.removing(element) testAfterOperation(mutableSet, immutableSet, element) } @@ -293,4 +293,4 @@ class PersistentHashSetTest : ExecutionTimeMeasuringTest() { assertEquals(expected.contains(element), actual.contains(element)) // assertEquals(expected, actual) } -} \ No newline at end of file +} diff --git a/core/jvmTest/src/contract/list/PersistentListGenerator.kt b/core/jvmTest/src/contract/list/PersistentListGenerator.kt index a2d95bc7..96ca4ba1 100644 --- a/core/jvmTest/src/contract/list/PersistentListGenerator.kt +++ b/core/jvmTest/src/contract/list/PersistentListGenerator.kt @@ -19,13 +19,13 @@ class PersistentListGenerator { object AddAll : TestStringListGenerator() { override fun create(elements: Array): List { - return persistentListOf().addAll(elements.toList()) + return persistentListOf().addingAll(elements.toList()) } } object AddEach : TestStringListGenerator() { override fun create(elements: Array): List { - return elements.fold(persistentListOf()) { list, element -> list.add(element) } + return elements.fold(persistentListOf()) { list, element -> list.adding(element) } } } @@ -44,7 +44,7 @@ class PersistentListGenerator { object HeadSubList : TestStringListGenerator() { override fun create(elements: Array): List { return persistentListOf() - .addAll(listOf(*elements, "f", "g")) + .addingAll(listOf(*elements, "f", "g")) .subList(0, elements.size) } } @@ -52,7 +52,7 @@ class PersistentListGenerator { object TailSubList : TestStringListGenerator() { override fun create(elements: Array): List { return persistentListOf() - .addAll(listOf("f", "g", *elements)) + .addingAll(listOf("f", "g", *elements)) .subList(2, elements.size + 2) } } @@ -61,7 +61,7 @@ class PersistentListGenerator { override fun create(elements: Array): List { return persistentListOf() - .addAll(listOf("f", "g", *elements, "h", "i")) + .addingAll(listOf("f", "g", *elements, "h", "i")) .subList(2, elements.size + 2) } } @@ -125,4 +125,4 @@ class PersistentListGenerator { } } } -} \ No newline at end of file +} diff --git a/core/jvmTest/src/contract/map/PersistentMapGenerator.kt b/core/jvmTest/src/contract/map/PersistentMapGenerator.kt index 856596a2..61288052 100644 --- a/core/jvmTest/src/contract/map/PersistentMapGenerator.kt +++ b/core/jvmTest/src/contract/map/PersistentMapGenerator.kt @@ -21,13 +21,13 @@ class PersistentMapGenerator { object PutAll : TestStringMapGenerator() { override fun create(entries: Array>): Map { val map = mutableMapOf().apply { entries.forEach { this[it.key] = it.value } } - return persistentHashMapOf().putAll(map) + return persistentHashMapOf().puttingAll(map) } } object PutEach : TestStringMapGenerator() { override fun create(entries: Array>): Map { - return entries.fold(persistentHashMapOf()) { map, entry -> map.put(entry.key, entry.value) } + return entries.fold(persistentHashMapOf()) { map, entry -> map.putting(entry.key, entry.value) } } } @@ -76,13 +76,13 @@ class PersistentMapGenerator { object PutAll : TestStringMapGenerator() { override fun create(entries: Array>): Map { val map = mutableMapOf().apply { entries.forEach { this[it.key] = it.value } } - return persistentMapOf().putAll(map) + return persistentMapOf().puttingAll(map) } } object PutEach : TestStringMapGenerator() { override fun create(entries: Array>): Map { - return entries.fold(persistentMapOf()) { map, entry -> map.put(entry.key, entry.value) } + return entries.fold(persistentMapOf()) { map, entry -> map.putting(entry.key, entry.value) } } } @@ -120,4 +120,4 @@ class PersistentMapGenerator { } } } -} \ No newline at end of file +} diff --git a/core/jvmTest/src/contract/set/PersistentSetGenerator.kt b/core/jvmTest/src/contract/set/PersistentSetGenerator.kt index 2baac54a..c4473e75 100644 --- a/core/jvmTest/src/contract/set/PersistentSetGenerator.kt +++ b/core/jvmTest/src/contract/set/PersistentSetGenerator.kt @@ -20,13 +20,13 @@ class PersistentSetGenerator { object AddAll : TestStringSetGenerator() { override fun create(elements: Array): Set { - return persistentHashSetOf().addAll(elements.toList()) + return persistentHashSetOf().addingAll(elements.toList()) } } object AddEach : TestStringSetGenerator() { override fun create(elements: Array): Set { - return elements.fold(persistentHashSetOf()) { set, element -> set.add(element) } + return elements.fold(persistentHashSetOf()) { set, element -> set.adding(element) } } } @@ -74,13 +74,13 @@ class PersistentSetGenerator { object AddAll : TestStringSetGenerator() { override fun create(elements: Array): Set { - return persistentSetOf().addAll(elements.toList()) + return persistentSetOf().addingAll(elements.toList()) } } object AddEach : TestStringSetGenerator() { override fun create(elements: Array): Set { - return elements.fold(persistentSetOf()) { set, element -> set.add(element) } + return elements.fold(persistentSetOf()) { set, element -> set.adding(element) } } } @@ -117,4 +117,4 @@ class PersistentSetGenerator { } } } -} \ No newline at end of file +}