Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9e1459b
Deprecate `add()` in favor of `adding()` across persistent collection…
DmitryNekrasov Oct 24, 2025
2ec72e5
Deprecate `addAll()` in favor of `addingAll()` across persistent coll…
DmitryNekrasov Oct 24, 2025
e0a1b4c
Deprecate `remove()` in favor of `removing()` across persistent colle…
DmitryNekrasov Oct 24, 2025
3ac8c34
Deprecate `removeAll()` in favor of `removingAll()` across persistent…
DmitryNekrasov Oct 24, 2025
7c4bd77
Deprecate `removeAll()` in favor of `removingAll()` across persistent…
DmitryNekrasov Oct 24, 2025
e008eb2
Deprecate `retainAll()` in favor of `retainingAll()` across persisten…
DmitryNekrasov Oct 24, 2025
6ebcd13
Deprecate `clear()` in favor of `cleared()` across persistent collect…
DmitryNekrasov Oct 24, 2025
77d5279
Deprecate `addAll()` in favor of `addingAll()` across persistent coll…
DmitryNekrasov Oct 24, 2025
0d16c3e
Deprecate `set()` in favor of `replacingAt()` across persistent colle…
DmitryNekrasov Oct 24, 2025
d2bc8d9
Deprecate `add()` in favor of `adding()` across persistent collection…
DmitryNekrasov Oct 24, 2025
de71b17
Deprecate `removeAt()` in favor of `removingAt()` across persistent c…
DmitryNekrasov Oct 24, 2025
6abe4fa
Deprecate `put()` in favor of `putting()` across persistent map imple…
DmitryNekrasov Oct 24, 2025
d5c528c
Deprecate `remove()` in favor of `removing()` across persistent map i…
DmitryNekrasov Oct 24, 2025
def28b8
Deprecate `remove()` in favor of `removing()` across persistent map i…
DmitryNekrasov Oct 24, 2025
941a40b
Deprecate `putAll()` in favor of `puttingAll()` across persistent map…
DmitryNekrasov Oct 24, 2025
03b250b
Deprecate `clear()` in favor of `cleared()` across persistent map imp…
DmitryNekrasov Oct 24, 2025
8343a71
Deprecate `putAll()` in favor of `puttingAll()` across persistent map…
DmitryNekrasov Oct 27, 2025
e579693
Update .api files
DmitryNekrasov Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions benchmarks/commonMain/src/benchmarks/immutableList/Add.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open class Add {
*/
@Benchmark
fun addFirst(): ImmutableList<String> {
return persistentListAdd(size - 1).add(0, "another element")
return persistentListAdd(size - 1).adding(0, "another element")
}

/**
Expand All @@ -60,6 +60,6 @@ open class Add {
*/
@Benchmark
fun addMiddle(): ImmutableList<String> {
return persistentListAdd(size - 1).add(size / 2, "another element")
return persistentListAdd(size - 1).adding(size / 2, "another element")
}
}
}
16 changes: 8 additions & 8 deletions benchmarks/commonMain/src/benchmarks/immutableList/AddAll.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ open class AddAll {
*/
@Benchmark
fun addAllLast(): ImmutableList<String> {
return persistentListOf<String>().addAll(listToAdd)
return persistentListOf<String>().addingAll(listToAdd)
}

/**
Expand All @@ -46,7 +46,7 @@ open class AddAll {
fun addAllLast_Half(): ImmutableList<String> {
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)
}

/**
Expand All @@ -57,7 +57,7 @@ open class AddAll {
fun addAllLast_OneThird(): ImmutableList<String> {
val initialSize = size - size / 3
val subListToAdd = listToAdd.subList(0, size - initialSize)
return persistentListAdd(initialSize).addAll(subListToAdd)
return persistentListAdd(initialSize).addingAll(subListToAdd)
}

/**
Expand All @@ -68,7 +68,7 @@ open class AddAll {
fun addAllFirst_Half(): ImmutableList<String> {
val initialSize = size / 2
val subListToAdd = listToAdd.subList(0, size - initialSize)
return persistentListAdd(initialSize).addAll(0, subListToAdd)
return persistentListAdd(initialSize).addingAll(0, subListToAdd)
}

/**
Expand All @@ -79,7 +79,7 @@ open class AddAll {
fun addAllFirst_OneThird(): ImmutableList<String> {
val initialSize = size - size / 3
val subListToAdd = listToAdd.subList(0, size - initialSize)
return persistentListAdd(initialSize).addAll(0, subListToAdd)
return persistentListAdd(initialSize).addingAll(0, subListToAdd)
}

/**
Expand All @@ -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)
}

/**
Expand All @@ -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)
}
}
}
8 changes: 4 additions & 4 deletions benchmarks/commonMain/src/benchmarks/immutableList/Remove.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class Remove {
fun removeLast(): ImmutableList<String> {
var list = persistentList
repeat(times = size) {
list = list.removeAt(list.size - 1)
list = list.removingAt(list.size - 1)
}
return list
}
Expand All @@ -43,7 +43,7 @@ open class Remove {
@Benchmark
fun removeFirst(): ImmutableList<String> {
val list = persistentList
return list.removeAt(0)
return list.removingAt(0)
}

/**
Expand All @@ -57,6 +57,6 @@ open class Remove {
@Benchmark
fun removeMiddle(): ImmutableList<String> {
val list = persistentList
return list.removeAt(size / 2)
return list.removingAt(size / 2)
}
}
}
14 changes: 7 additions & 7 deletions benchmarks/commonMain/src/benchmarks/immutableList/RemoveAll.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ open class RemoveAll {

@Setup
fun prepare() {
persistentList = persistentListOf<Int>().addAll(List(size) { it })
persistentList = persistentListOf<Int>().addingAll(List(size) { it })
}

// Results of the following benchmarks do not indicate memory or time spent per operation,
Expand All @@ -38,7 +38,7 @@ open class RemoveAll {
fun removeAll_All(): PersistentList<Int> {
val list = persistentList
val elementsToRemove = List(size) { it }
return list.removeAll(elementsToRemove)
return list.removingAll(elementsToRemove)
}

/**
Expand All @@ -48,7 +48,7 @@ open class RemoveAll {
fun removeAll_RandomHalf(): PersistentList<Int> {
val list = persistentList
val elementsToRemove = randomIndexes(size / 2)
return list.removeAll(elementsToRemove)
return list.removingAll(elementsToRemove)
}

/**
Expand All @@ -58,7 +58,7 @@ open class RemoveAll {
fun removeAll_RandomTen(): PersistentList<Int> {
val list = persistentList
val elementsToRemove = randomIndexes(10)
return list.removeAll(elementsToRemove)
return list.removingAll(elementsToRemove)
}

/**
Expand All @@ -68,7 +68,7 @@ open class RemoveAll {
fun removeAll_Tail(): PersistentList<Int> {
val list = persistentList
val elementsToRemove = List(tailSize()) { size - 1 - it }
return list.removeAll(elementsToRemove)
return list.removingAll(elementsToRemove)
}

/**
Expand All @@ -78,7 +78,7 @@ open class RemoveAll {
fun removeAll_NonExisting(): PersistentList<Int> {
val list = persistentList
val elementsToRemove = randomIndexes(10).map { size + it }
return list.removeAll(elementsToRemove)
return list.removingAll(elementsToRemove)
}

private fun randomIndexes(count: Int): List<Int> {
Expand All @@ -89,4 +89,4 @@ open class RemoveAll {
val bufferSize = 32
return (size and (bufferSize - 1)).let { if (it == 0) bufferSize else it }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ open class RemoveAllPredicate {
tailElementsPredicate = { it in tailElements }

val allElements = List(size) { it.toString() }
persistentList = persistentListOf<String>().addAll(allElements)
persistentList = persistentListOf<String>().addingAll(allElements)
}

// The benchmarks measure (time and memory spent in `removeAll` operation) / size
Expand All @@ -50,37 +50,37 @@ open class RemoveAllPredicate {
/** Removes all elements. */
@Benchmark
fun removeAll_All(): PersistentList<String> {
return persistentList.removeAll(truePredicate)
return persistentList.removingAll(truePredicate)
}

/** Removes no elements. */
@Benchmark
fun removeAll_Non(): PersistentList<String> {
return persistentList.removeAll(falsePredicate)
return persistentList.removingAll(falsePredicate)
}

/** Removes half of the elements randomly selected. */
@Benchmark
fun removeAll_RandomHalf(): PersistentList<String> {
return persistentList.removeAll(randomHalfElementsPredicate)
return persistentList.removingAll(randomHalfElementsPredicate)
}

/** Removes 10 random elements. */
@Benchmark
fun removeAll_RandomTen(): PersistentList<String> {
return persistentList.removeAll(randomTenElementsPredicate)
return persistentList.removingAll(randomTenElementsPredicate)
}

/** Removes a random element. */
@Benchmark
fun removeAll_RandomOne(): PersistentList<String> {
return persistentList.removeAll(randomOneElementPredicate)
return persistentList.removingAll(randomOneElementPredicate)
}

/** Removes last [tailSize] elements. */
@Benchmark
fun removeAll_Tail(): PersistentList<String> {
return persistentList.removeAll(tailElementsPredicate)
return persistentList.removingAll(tailElementsPredicate)
}

private fun randomIndexes(count: Int): List<Int> {
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/commonMain/src/benchmarks/immutableList/Set.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ open class Set {
@Benchmark
fun setByIndex(): ImmutableList<String> {
repeat(times = size) { index ->
persistentList = persistentList.set(index, "another element")
persistentList = persistentList.replacingAt(index, "another element")
}
return persistentList
}

@Benchmark
fun setByRandomIndex(): ImmutableList<String> {
repeat(times = size) { index ->
persistentList = persistentList.set(randomIndices[index], "another element")
persistentList = persistentList.replacingAt(randomIndices[index], "another element")
}
return persistentList
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ open class RemoveAll {
val immutableSize = immutableSize(size, immutablePercentage)
var list = persistentListOf<Int>()
for (i in 0 until immutableSize) {
list = list.add(i)
list = list.adding(i)
}
val builder = list.builder()
for (i in immutableSize until size) {
Expand All @@ -103,4 +103,4 @@ open class RemoveAll {
val bufferSize = 32
return (size and (bufferSize - 1)).let { if (it == 0) bufferSize else it }
}
}
}
4 changes: 2 additions & 2 deletions benchmarks/commonMain/src/benchmarks/immutableList/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import kotlinx.collections.immutable.persistentListOf
fun persistentListAdd(size: Int): PersistentList<String> {
var list = persistentListOf<String>()
repeat(times = size) {
list = list.add("some element")
list = list.adding("some element")
}
return list
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -137,4 +137,4 @@ open class Canonicalization {
}
}
}
}
}
4 changes: 2 additions & 2 deletions benchmarks/commonMain/src/benchmarks/immutableMap/Equals.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand All @@ -40,4 +40,4 @@ open class Equals {
fun nearlyEquals() = persistentMap == slightlyDifferentMap
@Benchmark
fun notEquals() = persistentMap == veryDifferentMap
}
}
8 changes: 4 additions & 4 deletions benchmarks/commonMain/src/benchmarks/immutableMap/PutAll.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ open class PutAll {

@Benchmark
fun putAllEqualSize(): PersistentMap<IntWrapper, String> {
return lhs.putAll(rhs)
return lhs.puttingAll(rhs)
}

@Benchmark
fun putAllSmallIntoLarge(): PersistentMap<IntWrapper, String> {
return lhs.putAll(rhsSmall)
return lhs.puttingAll(rhsSmall)
}

@Benchmark
fun putAllLargeIntoSmall(): PersistentMap<IntWrapper, String> {
return lhsSmall.putAll(rhs)
return lhsSmall.puttingAll(rhs)
}
}
}
4 changes: 2 additions & 2 deletions benchmarks/commonMain/src/benchmarks/immutableMap/Remove.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ open class Remove {
fun remove(): PersistentMap<IntWrapper, String> {
var map = persistentMap
repeat(times = size) { index ->
map = map.remove(keys[index])
map = map.removing(keys[index])
}
return map
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fun persistentMapBuilderPut(

var map = emptyPersistentMap<IntWrapper, String>(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()
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/commonMain/src/benchmarks/immutableMap/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ fun <K, V> emptyPersistentMap(implementation: String): PersistentMap<K, V> = whe
fun <K> persistentMapPut(implementation: String, keys: List<K>): PersistentMap<K, String> {
var map = emptyPersistentMap<K, String>(implementation)
for (key in keys) {
map = map.put(key, "some value")
map = map.putting(key, "some value")
}
return map
}

fun <K> persistentMapRemove(persistentMap: PersistentMap<K, String>, keys: List<K>): PersistentMap<K, String> {
var map = persistentMap
for (key in keys) {
map = map.remove(key)
map = map.removing(key)
}
return map
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -111,7 +111,7 @@ open class Canonicalization {
var set = halfHeightPersistentSet

for (element in elementsToRemove) {
set = set.add(element)
set = set.adding(element)
}

return set
Expand All @@ -137,4 +137,4 @@ open class Canonicalization {
}
}
}
}
}
Loading