Skip to content

Commit 544a8db

Browse files
committed
Renamed empty creation methods; Added map conversion methods
Additionally, prevented replaced-withs from ignoring type-paremeters, and added some gradle properties as the library didn't build.
1 parent 1d18389 commit 544a8db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+467
-243
lines changed

benchmarks/commonMain/src/benchmarks/immutableList/AddAll.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import benchmarks.*
99
import kotlinx.collections.immutable.ImmutableList
1010
import kotlinx.collections.immutable.persistentListOf
1111
import kotlinx.benchmark.*
12+
import kotlinx.collections.immutable.emptyPersistentList
1213

1314
@State(Scope.Benchmark)
1415
open class AddAll {
@@ -35,7 +36,7 @@ open class AddAll {
3536
*/
3637
@Benchmark
3738
fun addAllLast(): ImmutableList<String> {
38-
return persistentListOf<String>().addAll(listToAdd)
39+
return emptyPersistentList<String>().addAll(listToAdd)
3940
}
4041

4142
/**

benchmarks/commonMain/src/benchmarks/immutableList/Get.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import benchmarks.*
99
import kotlinx.collections.immutable.PersistentList
1010
import kotlinx.collections.immutable.persistentListOf
1111
import kotlinx.benchmark.*
12+
import kotlinx.collections.immutable.emptyPersistentList
1213

1314
@State(Scope.Benchmark)
1415
open class Get {
1516
@Param(BM_1, BM_10, BM_100, BM_1000, BM_10000, BM_100000, BM_1000000, BM_10000000)
1617
var size: Int = 0
1718

18-
private var persistentList: PersistentList<String> = persistentListOf()
19+
private var persistentList: PersistentList<String> = emptyPersistentList()
1920

2021
@Setup
2122
fun prepare() {

benchmarks/commonMain/src/benchmarks/immutableList/Iterate.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import benchmarks.*
99
import kotlinx.collections.immutable.PersistentList
1010
import kotlinx.collections.immutable.persistentListOf
1111
import kotlinx.benchmark.*
12+
import kotlinx.collections.immutable.emptyPersistentList
1213

1314
@State(Scope.Benchmark)
1415
open class Iterate {
1516
@Param(BM_1, BM_10, BM_100, BM_1000, BM_10000, BM_100000, BM_1000000, BM_10000000)
1617
var size: Int = 0
1718

18-
private var persistentList: PersistentList<String> = persistentListOf()
19+
private var persistentList: PersistentList<String> = emptyPersistentList()
1920

2021
@Setup
2122
fun prepare() {

benchmarks/commonMain/src/benchmarks/immutableList/Remove.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import kotlinx.collections.immutable.ImmutableList
1010
import kotlinx.collections.immutable.PersistentList
1111
import kotlinx.collections.immutable.persistentListOf
1212
import kotlinx.benchmark.*
13+
import kotlinx.collections.immutable.emptyPersistentList
1314

1415
@State(Scope.Benchmark)
1516
open class Remove {
1617
@Param(BM_1, BM_10, BM_100, BM_1000, BM_10000, BM_100000, BM_1000000, BM_10000000)
1718
var size: Int = 0
1819

19-
private var persistentList: PersistentList<String> = persistentListOf()
20+
private var persistentList: PersistentList<String> = emptyPersistentList()
2021

2122
@Setup
2223
fun prepare() {

benchmarks/commonMain/src/benchmarks/immutableList/RemoveAll.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ import benchmarks.*
99
import kotlinx.collections.immutable.PersistentList
1010
import kotlinx.collections.immutable.persistentListOf
1111
import kotlinx.benchmark.*
12+
import kotlinx.collections.immutable.emptyPersistentList
1213
import kotlin.random.Random
1314

1415
@State(Scope.Benchmark)
1516
open class RemoveAll {
1617
@Param(BM_1, BM_10, BM_100, BM_1000, BM_10000, BM_100000, BM_1000000, BM_10000000)
1718
var size: Int = 0
1819

19-
private var persistentList: PersistentList<Int> = persistentListOf()
20+
private var persistentList: PersistentList<Int> = emptyPersistentList()
2021

2122
@Setup
2223
fun prepare() {
23-
persistentList = persistentListOf<Int>().addAll(List(size) { it })
24+
persistentList = emptyPersistentList<Int>().addAll(List(size) { it })
2425
}
2526

2627
// Results of the following benchmarks do not indicate memory or time spent per operation,

benchmarks/commonMain/src/benchmarks/immutableList/RemoveAllPredicate.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package benchmarks.immutableList
88
import benchmarks.*
99
import kotlinx.collections.immutable.PersistentList
1010
import kotlinx.benchmark.*
11+
import kotlinx.collections.immutable.emptyPersistentList
1112
import kotlinx.collections.immutable.persistentListOf
1213
import kotlin.random.Random
1314

@@ -16,7 +17,7 @@ open class RemoveAllPredicate {
1617
@Param(BM_1, BM_10, BM_100, BM_1000, BM_10000, BM_100000, BM_1000000, BM_10000000)
1718
var size: Int = 0
1819

19-
private var persistentList = persistentListOf<String>()
20+
private var persistentList = emptyPersistentList<String>()
2021
private val truePredicate: (String) -> Boolean = { true }
2122
private val falsePredicate: (String) -> Boolean = { false }
2223
private var randomHalfElementsPredicate: (String) -> Boolean = truePredicate
@@ -39,7 +40,7 @@ open class RemoveAllPredicate {
3940
tailElementsPredicate = { it in tailElements }
4041

4142
val allElements = List(size) { it.toString() }
42-
persistentList = persistentListOf<String>().addAll(allElements)
43+
persistentList = emptyPersistentList<String>().addAll(allElements)
4344
}
4445

4546
// The benchmarks measure (time and memory spent in `removeAll` operation) / size

benchmarks/commonMain/src/benchmarks/immutableList/Set.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import kotlinx.collections.immutable.ImmutableList
1010
import kotlinx.collections.immutable.PersistentList
1111
import kotlinx.collections.immutable.persistentListOf
1212
import kotlinx.benchmark.*
13+
import kotlinx.collections.immutable.emptyPersistentList
1314

1415
@State(Scope.Benchmark)
1516
open class Set {
1617
@Param(BM_1, BM_10, BM_100, BM_1000, BM_10000, BM_100000, BM_1000000, BM_10000000)
1718
var size: Int = 0
1819

19-
private var persistentList: PersistentList<String> = persistentListOf()
20+
private var persistentList: PersistentList<String> = emptyPersistentList()
2021
private var randomIndices = listOf<Int>()
2122

2223
@Setup

benchmarks/commonMain/src/benchmarks/immutableList/builder/AddAll.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import benchmarks.*
99
import kotlinx.collections.immutable.PersistentList
1010
import kotlinx.collections.immutable.persistentListOf
1111
import kotlinx.benchmark.*
12+
import kotlinx.collections.immutable.emptyPersistentList
1213

1314
@State(Scope.Benchmark)
1415
open class AddAll {
@@ -38,7 +39,7 @@ open class AddAll {
3839
*/
3940
@Benchmark
4041
fun addAllLast(): PersistentList.Builder<String> {
41-
val builder = persistentListOf<String>().builder()
42+
val builder = emptyPersistentList<String>().builder()
4243
builder.addAll(listToAdd)
4344
return builder
4445
}

benchmarks/commonMain/src/benchmarks/immutableList/builder/Get.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package benchmarks.immutableList.builder
88
import benchmarks.*
99
import kotlinx.collections.immutable.persistentListOf
1010
import kotlinx.benchmark.*
11+
import kotlinx.collections.immutable.emptyPersistentList
1112

1213
@State(Scope.Benchmark)
1314
open class Get {
@@ -17,7 +18,7 @@ open class Get {
1718
@Param(IP_100, IP_99_09, IP_95, IP_70, IP_50, IP_30, IP_0)
1819
var immutablePercentage: Double = 0.0
1920

20-
private var builder = persistentListOf<String>().builder()
21+
private var builder = emptyPersistentList<String>().builder()
2122

2223
@Setup
2324
fun prepare() {

benchmarks/commonMain/src/benchmarks/immutableList/builder/Iterate.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package benchmarks.immutableList.builder
88
import benchmarks.*
99
import kotlinx.collections.immutable.persistentListOf
1010
import kotlinx.benchmark.*
11+
import kotlinx.collections.immutable.emptyPersistentList
1112

1213
@State(Scope.Benchmark)
1314
open class Iterate {
@@ -17,7 +18,7 @@ open class Iterate {
1718
@Param(IP_100, IP_99_09, IP_95, IP_70, IP_50, IP_30, IP_0)
1819
var immutablePercentage: Double = 0.0
1920

20-
private var builder = persistentListOf<String>().builder()
21+
private var builder = emptyPersistentList<String>().builder()
2122

2223
@Setup
2324
fun prepare() {

0 commit comments

Comments
 (0)