diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..b927a29
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,23 @@
+# .editorconfig
+root = true
+
+[*.{kt,kts}]
+end_of_line = lf
+ij_kotlin_packages_to_use_import_on_demand = true
+ij_kotlin_allow_trailing_comma = true
+ij_kotlin_allow_trailing_comma_on_call_site = true
+ij_kotlin_imports_layout = *
+ij_kotlin_indent_before_arrow_on_new_line = false
+ij_kotlin_line_break_after_multiline_when_entry = true
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 8
+ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than = 4
+ktlint_code_style = android_studio
+ktlint_enum_entry_name_casing = upper_or_camel_cases
+ktlint_function_naming_ignore_when_annotated_with = Composable
+ktlint_function_signature_body_expression_wrapping = default
+ktlint_ignore_back_ticked_identifier = false
+max_line_length = 140
+parameter-list-wrapping = true
\ No newline at end of file
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 482c298..846af42 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -20,7 +20,7 @@ jobs:
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Cache gradle
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
@@ -28,7 +28,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Cache konan
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
@@ -36,7 +36,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Run Gradle Build
- run: ./gradlew build --no-daemon --stacktrace --no-build-cache
+ run: ./gradlew ktlintCheck build --no-daemon --stacktrace --no-build-cache
env:
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
@@ -47,7 +47,7 @@ jobs:
- name: Upload Stately Collections Build Results
if: always()
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: deprecated-test-results
path: deprecated/**/build/reports/tests/
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 3df44b0..8121ed4 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -15,7 +15,7 @@ jobs:
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Cache gradle
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
@@ -23,7 +23,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Cache konan
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a5003bc..232c394 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -24,7 +24,7 @@ jobs:
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Cache gradle
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
@@ -32,7 +32,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Cache konan
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index c23569c..a1d5ac7 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -6,8 +6,6 @@
-
-
diff --git a/build.gradle.kts b/build.gradle.kts
index e0af3dc..2ae2347 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.dokka) apply false
alias(libs.plugins.touchlab.docusaurusosstemplate)
alias(libs.plugins.mavenPublish) apply false
+ id("org.jlleitschuh.gradle.ktlint") version "12.2.0" apply false
}
apiValidation {
@@ -26,4 +27,23 @@ val VERSION_NAME: String by project
allprojects {
group = GROUP
version = VERSION_NAME
+}
+
+subprojects {
+ apply(plugin = "org.jlleitschuh.gradle.ktlint")
+
+ configure {
+ version.set("1.4.0")
+ enableExperimentalRules.set(true)
+ verbose.set(true)
+ filter {
+ exclude { it.file.path.contains("build/") }
+ }
+ }
+
+ afterEvaluate {
+ tasks.named("check") {
+ dependsOn(tasks.getByName("ktlintCheck"))
+ }
+ }
}
\ No newline at end of file
diff --git a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/Functions.kt b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/Functions.kt
index ffbc350..6b71c31 100644
--- a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/Functions.kt
+++ b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/Functions.kt
@@ -27,8 +27,8 @@ expect fun frozenCopyOnWriteList(collection: Collection? = null): Mutable
message = "Replacing Atomic collections with isolated state collections (modele `stately-iso-collections`)",
replaceWith = ReplaceWith(
"sharedMutableListOf()",
- "co.touchlab.stately.collections.sharedMutableListOf"
- )
+ "co.touchlab.stately.collections.sharedMutableListOf",
+ ),
)
fun frozenLinkedList(stableIterator: Boolean = false): MutableList = if (stableIterator) {
CopyOnIterateLinkedList()
@@ -40,8 +40,8 @@ fun frozenLinkedList(stableIterator: Boolean = false): MutableList = if (
message = "Replacing Atomic collections with isolated state collections (modele `stately-iso-collections`)",
replaceWith = ReplaceWith(
"sharedMutableMapOf()",
- "co.touchlab.stately.collections.sharedMutableMapOf"
- )
+ "co.touchlab.stately.collections.sharedMutableMapOf",
+ ),
)
fun frozenHashMap(initialCapacity: Int = 16, loadFactor: Float = 0.75.toFloat()): MutableMap =
SharedHashMap(initialCapacity, loadFactor)
@@ -50,8 +50,8 @@ fun frozenHashMap(initialCapacity: Int = 16, loadFactor: Float = 0.75.toF
message = "Replacing Atomic collections with isolated state collections (modele `stately-iso-collections`)",
replaceWith = ReplaceWith(
"sharedMutableSetOf()",
- "co.touchlab.stately.collections.sharedMutableSetOf"
- )
+ "co.touchlab.stately.collections.sharedMutableSetOf",
+ ),
)
fun frozenHashSet(): MutableSet = SharedSet()
diff --git a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/ObjectPool.kt b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/ObjectPool.kt
index 31d0e69..b6ce140 100644
--- a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/ObjectPool.kt
+++ b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/ObjectPool.kt
@@ -7,11 +7,7 @@ import co.touchlab.stately.concurrency.value
import co.touchlab.stately.concurrency.withLock
import co.touchlab.stately.freeze
-class ObjectPool(
- private val maxSize: Int,
- private val createBlock: () -> T,
- private val cleanupBlock: ((t: T) -> Unit)? = null
-) {
+class ObjectPool(private val maxSize: Int, private val createBlock: () -> T, private val cleanupBlock: ((t: T) -> Unit)? = null) {
init {
if (maxSize < 0) {
throw IllegalArgumentException("maxSize cannot be negative")
diff --git a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedHashMap.kt b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedHashMap.kt
index f7c0a11..8fa26f6 100644
--- a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedHashMap.kt
+++ b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedHashMap.kt
@@ -35,9 +35,7 @@ class SharedHashMap(initialCapacity: Int = 16, val loadFactor: Float = 0.7
override val value: V
get() = v
- override fun setValue(newValue: V): V {
- throw UnsupportedOperationException()
- }
+ override fun setValue(newValue: V): V = throw UnsupportedOperationException()
}
private var lock: Lock = Lock()
@@ -56,8 +54,9 @@ class SharedHashMap(initialCapacity: Int = 16, val loadFactor: Float = 0.7
init {
var capacity = 1
- while (capacity < initialCapacity)
+ while (capacity < initialCapacity) {
capacity = capacity shl 1
+ }
threshold = AtomicInt((capacity.toFloat() * loadFactor).toInt())
buckets = AtomicReference(makeBuckets(capacity))
@@ -65,13 +64,11 @@ class SharedHashMap(initialCapacity: Int = 16, val loadFactor: Float = 0.7
freeze()
}
- private fun makeBuckets(capacity: Int): Array>>> {
- return (
- Array(capacity) {
- AtomicReference(SharedLinkedList>(1).freeze())
- }
- ).freeze()
- }
+ private fun makeBuckets(capacity: Int): Array>>> = (
+ Array(capacity) {
+ AtomicReference(SharedLinkedList>(1).freeze())
+ }
+ ).freeze()
private inline fun iterInternal(proc: (Entry) -> Unit) {
buckets.value.forEach {
@@ -115,31 +112,19 @@ class SharedHashMap(initialCapacity: Int = 16, val loadFactor: Float = 0.7
}
private class NotReallyMutableSet(private val delegate: MutableCollection) : MutableSet {
- override fun add(element: T): Boolean {
- throw UnsupportedOperationException()
- }
+ override fun add(element: T): Boolean = throw UnsupportedOperationException()
- override fun addAll(elements: Collection): Boolean {
- throw UnsupportedOperationException()
- }
+ override fun addAll(elements: Collection): Boolean = throw UnsupportedOperationException()
- override fun clear() {
- throw UnsupportedOperationException()
- }
+ override fun clear(): Unit = throw UnsupportedOperationException()
override fun iterator(): MutableIterator = delegate.iterator()
- override fun remove(element: T): Boolean {
- throw UnsupportedOperationException()
- }
+ override fun remove(element: T): Boolean = throw UnsupportedOperationException()
- override fun removeAll(elements: Collection): Boolean {
- throw UnsupportedOperationException()
- }
+ override fun removeAll(elements: Collection): Boolean = throw UnsupportedOperationException()
- override fun retainAll(elements: Collection): Boolean {
- throw UnsupportedOperationException()
- }
+ override fun retainAll(elements: Collection): Boolean = throw UnsupportedOperationException()
override val size: Int
get() = delegate.size
@@ -201,10 +186,7 @@ class SharedHashMap(initialCapacity: Int = 16, val loadFactor: Float = 0.7
return result
}
- private fun internalRemoveByKey(
- entryList: SharedLinkedList>,
- key: K
- ): V? {
+ private fun internalRemoveByKey(entryList: SharedLinkedList>, key: K): V? {
var result: AbstractSharedLinkedList.Node>? = null
val iter = entryList.nodeIterator()
while (iter.hasNext()) {
@@ -250,7 +232,7 @@ class SharedHashMap(initialCapacity: Int = 16, val loadFactor: Float = 0.7
private fun transfer(
newTable: Array>>>,
- oldTable: Array>>>
+ oldTable: Array>>>,
) {
oldTable.forEach {
it.value.iterator().forEach {
@@ -262,9 +244,7 @@ class SharedHashMap(initialCapacity: Int = 16, val loadFactor: Float = 0.7
internal fun currentBucketSize(): Int = buckets.value.size
- private fun indexFor(h: Int, length: Int): Int {
- return h and length - 1
- }
+ private fun indexFor(h: Int, length: Int): Int = h and length - 1
internal fun rehash(initHash: Int): Int {
var h = initHash
@@ -275,10 +255,7 @@ class SharedHashMap(initialCapacity: Int = 16, val loadFactor: Float = 0.7
return h xor h.ushr(7) xor h.ushr(4)
}
- private fun findEntryList(
- bucketArray: Array>>>,
- key: K
- ): SharedLinkedList> {
+ private fun findEntryList(bucketArray: Array>>>, key: K): SharedLinkedList> {
val hash = rehash(key.hashCode())
val entryList = bucketArray.get(indexFor(hash, bucketArray.size)).value
return entryList
diff --git a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedLinkedList.kt b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedLinkedList.kt
index d1c7c0b..231b4a8 100644
--- a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedLinkedList.kt
+++ b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedLinkedList.kt
@@ -57,9 +57,7 @@ class SharedLinkedList(objectPoolSize: Int = 0) : AbstractSharedLinkedList
fun nodeIterator(): MutableIterator> = NodeIterator(this, version.value)
class NodeIterator(private val ll: SharedLinkedList, private val version: Int) : MutableIterator> {
- override fun remove() {
- throw UnsupportedOperationException()
- }
+ override fun remove(): Unit = throw UnsupportedOperationException()
var currentNode = ll.head.value
@@ -83,9 +81,7 @@ class SharedLinkedList(objectPoolSize: Int = 0) : AbstractSharedLinkedList
}
class LLIterator(private val ll: SharedLinkedList, private val version: Int) : MutableIterator {
- override fun remove() {
- throw UnsupportedOperationException()
- }
+ override fun remove(): Unit = throw UnsupportedOperationException()
var currentNode = ll.head.value
@@ -133,11 +129,9 @@ class CopyOnIterateLinkedList(objectPoolSize: Int = 0) : AbstractSharedLinked
override fun iterator(): MutableIterator = LocalIterator(withLock(false) { checkUpdate() }.iterator())
- override fun listIterator(): MutableListIterator =
- LocalListIterator(withLock(false) { checkUpdate() }.listIterator())
+ override fun listIterator(): MutableListIterator = LocalListIterator(withLock(false) { checkUpdate() }.listIterator())
- override fun listIterator(index: Int): MutableListIterator =
- LocalListIterator(withLock(false) { checkUpdate() }.listIterator(index))
+ override fun listIterator(index: Int): MutableListIterator = LocalListIterator(withLock(false) { checkUpdate() }.listIterator(index))
private fun checkUpdate(): MutableList {
if (updated.value != 0) {
@@ -162,9 +156,7 @@ private open class LocalIterator(private val delegate: MutableIterator) :
override fun next(): T = delegate.next()
- override fun remove() {
- throw UnsupportedOperationException("Can't mutate list from iterator")
- }
+ override fun remove(): Unit = throw UnsupportedOperationException("Can't mutate list from iterator")
}
private class LocalListIterator(private val delegate: MutableListIterator) : MutableListIterator {
@@ -172,9 +164,7 @@ private class LocalListIterator(private val delegate: MutableListIterator)
override fun next(): T = delegate.next()
- override fun remove() {
- throw UnsupportedOperationException("Can't mutate list from iterator")
- }
+ override fun remove(): Unit = throw UnsupportedOperationException("Can't mutate list from iterator")
override fun hasPrevious(): Boolean = delegate.hasPrevious()
@@ -184,13 +174,9 @@ private class LocalListIterator(private val delegate: MutableListIterator)
override fun previousIndex(): Int = delegate.previousIndex()
- override fun add(element: T) {
- throw UnsupportedOperationException()
- }
+ override fun add(element: T): Unit = throw UnsupportedOperationException()
- override fun set(element: T) {
- throw UnsupportedOperationException()
- }
+ override fun set(element: T): Unit = throw UnsupportedOperationException()
}
abstract class AbstractSharedLinkedList(objectPoolSize: Int) : MutableList {
@@ -234,9 +220,7 @@ abstract class AbstractSharedLinkedList(objectPoolSize: Int) : MutableList
true
}
- override fun subList(fromIndex: Int, toIndex: Int): MutableList {
- throw UnsupportedOperationException()
- }
+ override fun subList(fromIndex: Int, toIndex: Int): MutableList = throw UnsupportedOperationException()
override val size: Int
get() = withLock(false) { sizeCount.value }
@@ -293,8 +277,7 @@ abstract class AbstractSharedLinkedList(objectPoolSize: Int) : MutableList
override fun contains(element: T): Boolean = withLock(false) { internalFindFirst(element) != null }
- override fun containsAll(elements: Collection): Boolean =
- withLock(false) { elements.all { internalFindFirst(it) != null } }
+ override fun containsAll(elements: Collection): Boolean = withLock(false) { elements.all { internalFindFirst(it) != null } }
override fun get(index: Int) = withLock(false) { internalNodeAt(index).nodeValue }
diff --git a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedLruCache.kt b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedLruCache.kt
index e163d61..c4bce48 100644
--- a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedLruCache.kt
+++ b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedLruCache.kt
@@ -39,10 +39,8 @@ import co.touchlab.stately.freeze
* case the onRemove logic intends to call back into the cache. This may have unintended consequences if you're expecting
* the mutation to be fully atomic in nature.
*/
-class SharedLruCache(
- private val maxCacheSize: Int,
- private val onRemove: (MutableMap.MutableEntry) -> Unit = {}
-) : LruCache {
+class SharedLruCache(private val maxCacheSize: Int, private val onRemove: (MutableMap.MutableEntry) -> Unit = {}) :
+ LruCache {
private var lock: Lock = Lock()
private val cacheMap = SharedHashMap>(initialCapacity = maxCacheSize)
@@ -188,13 +186,9 @@ class SharedLruCache(
class LruEntry(override val key: K, override val value: V) : MutableMap.MutableEntry {
- override fun setValue(newValue: V): V {
- throw UnsupportedOperationException()
- }
+ override fun setValue(newValue: V): V = throw UnsupportedOperationException()
- override fun toString(): String {
- return "LruEntry(key=$key, value=$value)"
- }
+ override fun toString(): String = "LruEntry(key=$key, value=$value)"
}
private fun internalAll(): HashSet> {
diff --git a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedSet.kt b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedSet.kt
index 50df919..f3b21e7 100644
--- a/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedSet.kt
+++ b/deprecated/stately-collections/src/commonMain/kotlin/co/touchlab/stately/collections/SharedSet.kt
@@ -31,12 +31,11 @@ class SharedSet : MutableSet {
return !result
}
- override fun addAll(elements: Collection): Boolean =
- elements.fold(false) { b, t ->
- val result = backingMap.containsKey(t)
- backingMap.put(t, Unit)
- b || result
- }
+ override fun addAll(elements: Collection): Boolean = elements.fold(false) { b, t ->
+ val result = backingMap.containsKey(t)
+ backingMap.put(t, Unit)
+ b || result
+ }
override fun clear() {
backingMap.clear()
@@ -48,12 +47,11 @@ class SharedSet : MutableSet {
return result
}
- override fun removeAll(elements: Collection): Boolean =
- elements.fold(false) { b, t ->
- val result = backingMap.containsKey(t)
- backingMap.remove(t)
- b || result
- }
+ override fun removeAll(elements: Collection): Boolean = elements.fold(false) { b, t ->
+ val result = backingMap.containsKey(t)
+ backingMap.remove(t)
+ b || result
+ }
override fun retainAll(elements: Collection): Boolean {
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
diff --git a/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedHashMapTest.kt b/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedHashMapTest.kt
index a8e4f78..ecf5364 100644
--- a/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedHashMapTest.kt
+++ b/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedHashMapTest.kt
@@ -126,8 +126,8 @@ class SharedHashMapTest {
m.entries,
SharedHashMap.Entry("Key: 0", MapData("Value: 0")),
SharedHashMap.Entry("Key: 1", MapData("Value: 1")),
- SharedHashMap.Entry("Key: 2", MapData("Value: 2"))
- )
+ SharedHashMap.Entry("Key: 2", MapData("Value: 2")),
+ ),
)
}
@@ -147,11 +147,11 @@ class SharedHashMapTest {
fun mtAddRemove() {
try {
println("mtAddRemove Start")
- val LOOPS = 200
+ val loops = 200
val ops = ThreadOperations { SharedHashMap() }
val removeOps = ThreadOperations { SharedHashMap() }
val m = SharedHashMap()
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
val key = "key $i"
val value = "val $i"
ops.exe { m.put(key, MapData(value)) }
@@ -169,7 +169,6 @@ class SharedHashMapTest {
e.printStackTrace()
throw e
}
-
}
/**
@@ -182,8 +181,8 @@ class SharedHashMapTest {
val ops = ThreadOperations { }
val removeOps = ThreadOperations { }
- val LOOPS = 500
- for (i in 0 until LOOPS) {
+ val loops = 500
+ for (i in 0 until loops) {
val key = "key $i"
ops.exe { map.put(BadHashKey(key), MapData("val $i")) }
ops.test { assertTrue { map.containsKey(BadHashKey(key)) } }
@@ -192,7 +191,7 @@ class SharedHashMapTest {
}
ops.run(threads = 8, randomize = true)
- assertEquals(LOOPS, map.size)
+ assertEquals(loops, map.size)
removeOps.run(threads = 8, randomize = true)
assertEquals(0, map.size)
}
@@ -205,11 +204,11 @@ class SharedHashMapTest {
@Test
@Ignore
fun testBasicThreads() {
- val WORKERS = 10
- val LOOP_INSERT = 200
- val LOOP_REMOVE = 15
+ val workerNum = 10
+ val loopInsert = 200
+ val loopRemove = 15
- val workers = Array(WORKERS) {
+ val workers = Array(workerNum) {
MPWorker()
}
@@ -223,11 +222,11 @@ class SharedHashMapTest {
val mycount = count.value
it.runBackground {
- for (i in 0 until LOOP_INSERT) {
+ for (i in 0 until loopInsert) {
val key = "W:$mycount I:$i"
m.put(key, MapData("W2:$mycount I2:$i"))
}
- for (i in 0 until LOOP_REMOVE) {
+ for (i in 0 until loopRemove) {
m.remove("W:$mycount I:${i * 10}")
}
}
@@ -237,7 +236,7 @@ class SharedHashMapTest {
workers.forEach { it.requestTermination() }
println("basic threads time: ${TimeSource.Monotonic.markNow().minus(start).inWholeMilliseconds}")
- val size = (LOOP_INSERT - LOOP_REMOVE) * WORKERS
+ val size = (loopInsert - loopRemove) * workerNum
assertEquals(m.size, size)
assertEquals(m.entries.size, size)
assertEquals(m.keys.size, size)
diff --git a/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedLinkedListTest.kt b/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedLinkedListTest.kt
index 9c48794..0d1d0c4 100644
--- a/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedLinkedListTest.kt
+++ b/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedLinkedListTest.kt
@@ -19,7 +19,6 @@ package co.touchlab.stately.collections
import co.touchlab.stately.concurrency.value
import co.touchlab.stately.freeze
import co.touchlab.testhelp.concurrency.ThreadOperations
-import co.touchlab.testhelp.isNativeFrozen
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFails
@@ -308,21 +307,21 @@ class LinkedListTest {
@Test
fun mtNodeAdd() {
- val LOOPS = 20
- val DOOPS = 20
+ val loops = 20
+ val doops = 20
val ll = SharedLinkedList().freeze()
val nodeList = mutableListOf>()
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
nodeList.add(ll.addNode(ListData("a $i")))
}
nodeList.freeze()
val ops = ThreadOperations { }
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
ops.exe {
val node = nodeList.get(i)
- for (j in 0 until DOOPS) {
+ for (j in 0 until doops) {
node.add(ListData("a $i sub $j"))
}
node.remove()
@@ -331,7 +330,7 @@ class LinkedListTest {
ops.run(8)
- assertEquals(DOOPS * LOOPS, ll.size)
+ assertEquals(doops * loops, ll.size)
var loopCount = 0
var doopCount = 0
@@ -353,7 +352,7 @@ class LinkedListTest {
assertEquals(ListData("a $loopCount sub $doopCount"), it)
doopCount++
- if (doopCount == DOOPS) {
+ if (doopCount == doops) {
doopCount = 0
loopCount++
}
@@ -365,17 +364,17 @@ class LinkedListTest {
*/
@Test
fun mtNodeRemove() {
- val LOOPS = 2_000
+ val loops = 2_000
val ll = SharedLinkedList().freeze()
val nodeList = mutableListOf>()
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
nodeList.add(ll.addNode(ListData("a $i")))
}
nodeList.freeze()
val ops = ThreadOperations { }
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
ops.exe {
val node = nodeList.get(i)
if (i % 100 == 0) {
@@ -387,7 +386,7 @@ class LinkedListTest {
ops.run(8)
- assertEquals(LOOPS / 100, ll.size)
+ assertEquals(loops / 100, ll.size)
}
/**
@@ -396,24 +395,24 @@ class LinkedListTest {
*/
@Test
fun mtNodeSet() {
- val LOOPS = 80
+ val loops = 80
val ll = SharedLinkedList().freeze()
val nodeList = mutableListOf>()
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
nodeList.add(ll.addNode(ListData("a $i")))
}
nodeList.freeze()
val ops = ThreadOperations { }
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
ops.exe { nodeList.get(i).set(ListData("b $i")) }
ops.test { assertEquals(ll.get(i), ListData("b $i")) }
}
ops.run(8, true)
- assertEquals(LOOPS, ll.size)
+ assertEquals(loops, ll.size)
}
/**
@@ -423,9 +422,9 @@ class LinkedListTest {
fun mtAdd() {
val ops = ThreadOperations { SharedLinkedList() }
- val LOOPS = 50
+ val loops = 50
- for (wcount in 0 until LOOPS) {
+ for (wcount in 0 until loops) {
ops.exe { ll ->
ll.add(ListData("$wcount 1"))
ll.add(ListData("$wcount 2"))
@@ -435,7 +434,7 @@ class LinkedListTest {
val ll = ops.run(threads = 5, randomize = true)
- assertEquals(LOOPS * 3, ll.size)
+ assertEquals(loops * 3, ll.size)
}
/**
@@ -443,11 +442,11 @@ class LinkedListTest {
*/
@Test
fun testBasicThreads() {
- val LOOPS = 500
+ val loops = 500
val ops = ThreadOperations { SharedLinkedList() }
val ll = SharedLinkedList().freeze()
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
ops.exe { ll.add(TestData("Value: $i")) }
ops.test { ll.contains(TestData("Value: $i")) }
}
@@ -468,7 +467,8 @@ class LinkedListTest {
//TODO: Figure out some threaded stress tests. The following
//was acting as intended but failing when trying to remove the same node
- *//*val countDownEnd = 100 * valCount
+ */
+/*val countDownEnd = 100 * valCount
var countDownStart = countDownEnd +
ll.nodeIterator().forEach {
@@ -482,13 +482,14 @@ class LinkedListTest {
collisionCount.increment()
}
}
- }*//*
+ }*/
+/*
}
}
workers.forEach { it.requestTermination() }*/
- assertEquals(LOOPS, ll.size)
+ assertEquals(loops, ll.size)
}
@Test
diff --git a/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedLruCacheTest.kt b/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedLruCacheTest.kt
index 883abff..1c9fdb0 100644
--- a/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedLruCacheTest.kt
+++ b/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/SharedLruCacheTest.kt
@@ -19,11 +19,8 @@ package co.touchlab.stately.collections
import co.touchlab.stately.concurrency.AtomicInt
import co.touchlab.stately.concurrency.value
import co.touchlab.testhelp.concurrency.ThreadOperations
-import co.touchlab.testhelp.isNative
-import co.touchlab.testhelp.isNativeFrozen
import kotlin.test.Test
import kotlin.test.assertEquals
-import kotlin.test.assertFails
import kotlin.test.assertNull
import kotlin.test.assertTrue
@@ -100,7 +97,7 @@ class SharedLruCacheTest {
MapData("Value: 2"),
MapData("Value: 0"),
MapData("Value: 1"),
- MapData("Value: 3")
+ MapData("Value: 3"),
)
assertEquals(sc.size, 0)
@@ -136,7 +133,7 @@ class SharedLruCacheTest {
MapData("Value: 0"),
MapData("Value: 1"),
MapData("Value: 2"),
- MapData("Value: 3")
+ MapData("Value: 3"),
)
sc.remove("Key: 1")
@@ -151,7 +148,7 @@ class SharedLruCacheTest {
MapData("Value: 3"),
MapData("Value: 2"),
MapData("Value: 0"),
- MapData("1")
+ MapData("1"),
)
sc.put("b", MapData("2"))
@@ -161,7 +158,7 @@ class SharedLruCacheTest {
MapData("Value: 2"),
MapData("Value: 0"),
MapData("1"),
- MapData("2")
+ MapData("2"),
)
}
@@ -282,23 +279,23 @@ class SharedLruCacheTest {
@Test
fun mtPutStress() {
- val CACHE_SIZE = 100
- val LOOPS = 100
+ val cacheSize = 100
+ val loops = 100
val count = AtomicInt(0)
val ops = ThreadOperations> {
- SharedLruCache(CACHE_SIZE) { count.incrementAndGet() }
+ SharedLruCache(cacheSize) { count.incrementAndGet() }
}
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
ops.exe {
it.put("key $i", MapData("data $i"))
}
}
val lru = ops.run(threads = 8, randomize = true)
- assertEquals(CACHE_SIZE, lru.size)
- assertEquals(LOOPS - CACHE_SIZE, count.value)
+ assertEquals(cacheSize, lru.size)
+ assertEquals(loops - cacheSize, count.value)
}
private fun checkExists(lru: LruCache, vararg keys: String) {
diff --git a/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/StableReadListTest.kt b/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/StableReadListTest.kt
index 152aea0..8174404 100644
--- a/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/StableReadListTest.kt
+++ b/deprecated/stately-collections/src/commonTest/kotlin/co/touchlab/stately/collections/StableReadListTest.kt
@@ -18,7 +18,6 @@ package co.touchlab.stately.collections
import co.touchlab.stately.freeze
import co.touchlab.testhelp.concurrency.ThreadOperations
-import co.touchlab.testhelp.isNativeFrozen
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFails
@@ -35,13 +34,13 @@ These implementations should function identically except for 'subList'. See test
// Ignored on JS because frozenCopyOnWriteList() is not implemented
@JsIgnore
-class CopyOnWriteListTest() : AbstractStableReadListTest() {
+class CopyOnWriteListTest : AbstractStableReadListTest() {
override val supportsSublist: Boolean = true
override fun createList(collection: Collection?): MutableList = frozenCopyOnWriteList()
}
-class CopyOnWriteLinkedListTest() : AbstractStableReadListTest() {
+class CopyOnWriteLinkedListTest : AbstractStableReadListTest() {
override val supportsSublist: Boolean = false
override fun createList(collection: Collection?): MutableList = frozenLinkedList(stableIterator = true)
@@ -52,7 +51,6 @@ abstract class AbstractStableReadListTest {
abstract fun createList(collection: Collection? = null): MutableList
abstract val supportsSublist: Boolean
-
@Test
fun testStableReads() {
val list = createList()
@@ -110,16 +108,20 @@ abstract class AbstractStableReadListTest {
assertTrue(
list.containsAll(
mutableListOf(
- ListData("a 5"), ListData("a 15"), ListData("a 50")
- )
- )
+ ListData("a 5"),
+ ListData("a 15"),
+ ListData("a 50"),
+ ),
+ ),
)
assertFalse(
list.containsAll(
mutableListOf(
- ListData("a 5"), ListData("a 15"), ListData("a 500")
- )
- )
+ ListData("a 5"),
+ ListData("a 15"),
+ ListData("a 500"),
+ ),
+ ),
)
}
@@ -179,29 +181,29 @@ abstract class AbstractStableReadListTest {
@Test
fun mtAdd() {
- val LOOPS = 500
+ val loops = 500
val tops = ThreadOperations { createList() }
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
val key = "Add: $i"
tops.exe { it.add(ListData(key)) }
tops.test { list -> assertTrue(list.contains(ListData(key))) }
}
val list = tops.run(8)
- assertEquals(list.size, LOOPS)
+ assertEquals(list.size, loops)
println("mtAdd: ${tops.lastRunTime}")
}
@Test
fun mtAddAt() {
- val LOOPS = 100
+ val loops = 100
val tops = ThreadOperations { createList() }
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
val key = "Add: $i"
tops.exe {
val index = if (it.size == 0) {
@@ -220,16 +222,16 @@ abstract class AbstractStableReadListTest {
list.add(list.size + 1, ListData("Never"))
}
- assertEquals(list.size, LOOPS)
+ assertEquals(list.size, loops)
}
@Test
fun mtAddAll() {
- val LOOPS = 100
+ val loops = 100
val tops = ThreadOperations { createList() }
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
val key = "Add: $i"
tops.exe { it.addAll(listOf(ListData("$key 0"), ListData("$key 1"), ListData("$key 2"))) }
tops.test { list ->
@@ -240,16 +242,16 @@ abstract class AbstractStableReadListTest {
}
val list = tops.run(8)
- assertEquals(list.size, LOOPS * 3)
+ assertEquals(list.size, loops * 3)
}
@Test
fun mtAddAllAt() {
- val LOOPS = 100
+ val loops = 100
val tops = ThreadOperations { createList() }
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
val key = "Add: $i"
tops.exe {
val index = if (it.size == 0) {
@@ -272,7 +274,7 @@ abstract class AbstractStableReadListTest {
list.add(list.size + 1, ListData("Never"))
}
- assertEquals(list.size, LOOPS * 3)
+ assertEquals(list.size, loops * 3)
}
@Test
@@ -290,11 +292,11 @@ abstract class AbstractStableReadListTest {
@Test
fun mtRemove() {
- val LOOPS = 500
+ val loops = 500
val list = createList().freeze()
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
val key = "Add: $i"
list.add(ListData(key))
}
@@ -303,14 +305,14 @@ abstract class AbstractStableReadListTest {
val tops = ThreadOperations { }
- for (i in 0 until LOOPS) {
+ for (i in 0 until loops) {
val key = "Add: $i"
tops.exe { list.remove(ListData(key)) }
}
tops.run(8)
assertEquals(list.size, 0)
- assertEquals(iter.toList().size, LOOPS)
+ assertEquals(iter.toList().size, loops)
}
@Test
diff --git a/deprecated/stately-collections/src/jsAndWasmJsMain/kotlin/co/touchlab/stately/collections/Functions.kt b/deprecated/stately-collections/src/jsAndWasmJsMain/kotlin/co/touchlab/stately/collections/Functions.kt
index 0ddd062..ed7617c 100644
--- a/deprecated/stately-collections/src/jsAndWasmJsMain/kotlin/co/touchlab/stately/collections/Functions.kt
+++ b/deprecated/stately-collections/src/jsAndWasmJsMain/kotlin/co/touchlab/stately/collections/Functions.kt
@@ -5,6 +5,4 @@ package co.touchlab.stately.collections
* [https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CopyOnWriteArrayList.html](CopyOnWriteArrayList).
* On Native, there is a native implementation which maintains and updates a frozen ArrayList.
*/
-actual fun frozenCopyOnWriteList(collection: Collection?): MutableList {
- throw UnsupportedOperationException("Not for JS or Wasm")
-}
+actual fun frozenCopyOnWriteList(collection: Collection?): MutableList = throw UnsupportedOperationException("Not for JS or Wasm")
diff --git a/deprecated/stately-collections/src/jvmMain/kotlin/co/touchlab/stately/collections/FunctionsJVM.kt b/deprecated/stately-collections/src/jvmMain/kotlin/co/touchlab/stately/collections/FunctionsJVM.kt
index 6042870..46f2ab9 100644
--- a/deprecated/stately-collections/src/jvmMain/kotlin/co/touchlab/stately/collections/FunctionsJVM.kt
+++ b/deprecated/stately-collections/src/jvmMain/kotlin/co/touchlab/stately/collections/FunctionsJVM.kt
@@ -18,10 +18,8 @@ package co.touchlab.stately.collections
import java.util.concurrent.CopyOnWriteArrayList
-actual fun frozenCopyOnWriteList(collection: Collection?): MutableList {
- return if (collection == null) {
- CopyOnWriteArrayList()
- } else {
- CopyOnWriteArrayList(collection)
- }
+actual fun frozenCopyOnWriteList(collection: Collection?): MutableList = if (collection == null) {
+ CopyOnWriteArrayList()
+} else {
+ CopyOnWriteArrayList(collection)
}
diff --git a/deprecated/stately-collections/src/nativeMain/kotlin/co/touchlab/stately/collections/CopyOnWriteList.kt b/deprecated/stately-collections/src/nativeMain/kotlin/co/touchlab/stately/collections/CopyOnWriteList.kt
index 0afa4eb..d75243f 100644
--- a/deprecated/stately-collections/src/nativeMain/kotlin/co/touchlab/stately/collections/CopyOnWriteList.kt
+++ b/deprecated/stately-collections/src/nativeMain/kotlin/co/touchlab/stately/collections/CopyOnWriteList.kt
@@ -73,8 +73,7 @@ class CopyOnWriteList(elements: Collection) : MutableList {
override fun isEmpty(): Boolean = listData.value.isEmpty()
- override fun iterator(): MutableIterator =
- LocalIterator(listData.value)
+ override fun iterator(): MutableIterator = LocalIterator(listData.value)
override fun lastIndexOf(element: T): Int = listData.value.lastIndexOf(element)
@@ -88,11 +87,9 @@ class CopyOnWriteList(elements: Collection) : MutableList {
override fun clear() = modifyList { it.clear() }
- override fun listIterator(): MutableListIterator =
- LocalListIterator(listData.value)
+ override fun listIterator(): MutableListIterator = LocalListIterator(listData.value)
- override fun listIterator(index: Int): MutableListIterator =
- LocalListIterator(listData.value, index)
+ override fun listIterator(index: Int): MutableListIterator = LocalListIterator(listData.value, index)
override fun remove(element: T): Boolean = modifyList { it.remove(element) }
@@ -112,13 +109,12 @@ class CopyOnWriteList(elements: Collection) : MutableList {
override fun next(): T = list.get(index.addAndGet(1) - 1)
- override fun remove() {
- throw UnsupportedOperationException("Can't mutate list from iterator")
- }
+ override fun remove(): Unit = throw UnsupportedOperationException("Can't mutate list from iterator")
}
private class LocalListIterator(private val list: List, startIndex: Int = 0) :
- LocalIterator(list, startIndex), MutableListIterator {
+ LocalIterator(list, startIndex),
+ MutableListIterator {
override fun hasPrevious(): Boolean = index.value > 0
override fun nextIndex(): Int = index.value
@@ -127,12 +123,8 @@ class CopyOnWriteList(elements: Collection) : MutableList {
override fun previousIndex(): Int = index.value - 1
- override fun add(element: T) {
- throw UnsupportedOperationException()
- }
+ override fun add(element: T): Unit = throw UnsupportedOperationException()
- override fun set(element: T) {
- throw UnsupportedOperationException()
- }
+ override fun set(element: T): Unit = throw UnsupportedOperationException()
}
}
diff --git a/deprecated/stately-collections/src/nativeMain/kotlin/co/touchlab/stately/collections/Functions.kt b/deprecated/stately-collections/src/nativeMain/kotlin/co/touchlab/stately/collections/Functions.kt
index 27e7089..8a4a98a 100644
--- a/deprecated/stately-collections/src/nativeMain/kotlin/co/touchlab/stately/collections/Functions.kt
+++ b/deprecated/stately-collections/src/nativeMain/kotlin/co/touchlab/stately/collections/Functions.kt
@@ -16,10 +16,8 @@
package co.touchlab.stately.collections
-actual fun frozenCopyOnWriteList(collection: Collection?): MutableList {
- return if (collection == null) {
- CopyOnWriteList()
- } else {
- CopyOnWriteList(collection)
- }
+actual fun frozenCopyOnWriteList(collection: Collection?): MutableList = if (collection == null) {
+ CopyOnWriteList()
+} else {
+ CopyOnWriteList(collection)
}
diff --git a/deprecated/stately-common/src/commonTest/kotlin/co/touchlab/stately/HelpersTest.kt b/deprecated/stately-common/src/commonTest/kotlin/co/touchlab/stately/HelpersTest.kt
index 82b4d27..b942ce9 100644
--- a/deprecated/stately-common/src/commonTest/kotlin/co/touchlab/stately/HelpersTest.kt
+++ b/deprecated/stately-common/src/commonTest/kotlin/co/touchlab/stately/HelpersTest.kt
@@ -16,7 +16,6 @@
package co.touchlab.stately
-
class HelpersTest {
// @Test
// fun ensureNeverFrozenNoFreezeChild() {
diff --git a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoArrayDeque.kt b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoArrayDeque.kt
index 9faabab..b673339 100644
--- a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoArrayDeque.kt
+++ b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoArrayDeque.kt
@@ -5,9 +5,11 @@ import co.touchlab.stately.isolate.StateRunner
import co.touchlab.stately.isolate.createState
open class IsoArrayDeque
-internal constructor(stateHolder: StateHolder>) :
- IsoMutableList(stateHolder) {
- constructor(stateRunner: StateRunner? = null, producer: () -> ArrayDeque = { ArrayDeque() }) : this(createState(stateRunner, producer))
+internal constructor(stateHolder: StateHolder>) : IsoMutableList(stateHolder) {
+ constructor(
+ stateRunner: StateRunner? = null,
+ producer: () -> ArrayDeque = { ArrayDeque() },
+ ) : this(createState(stateRunner, producer))
/**
* Returns the first element, or throws [NoSuchElementException] if this deque is empty.
@@ -59,6 +61,5 @@ internal constructor(stateHolder: StateHolder>) :
*/
public fun removeLastOrNull(): E? = asAccess { it.removeLastOrNull() }
- private inline fun asAccess(crossinline block: (ArrayDeque) -> R): R =
- access { block(it as ArrayDeque) }
+ private inline fun asAccess(crossinline block: (ArrayDeque) -> R): R = access { block(it as ArrayDeque) }
}
diff --git a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableCollection.kt b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableCollection.kt
index 04f2e4d..858c122 100644
--- a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableCollection.kt
+++ b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableCollection.kt
@@ -6,16 +6,13 @@ import co.touchlab.stately.isolate.StateRunner
import co.touchlab.stately.isolate.createState
open class IsoMutableCollection internal constructor(stateHolder: StateHolder>) :
- IsolateState>(stateHolder), MutableCollection {
+ IsolateState>(stateHolder),
+ MutableCollection {
constructor(stateRunner: StateRunner? = null, producer: () -> MutableCollection) : this(createState(stateRunner, producer))
- override fun equals(other: Any?): Boolean {
- return access { it == other }
- }
+ override fun equals(other: Any?): Boolean = access { it == other }
- override fun hashCode(): Int {
- return access { it.hashCode() }
- }
+ override fun hashCode(): Int = access { it.hashCode() }
override val size: Int
get() = access { it.size }
diff --git a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableIterator.kt b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableIterator.kt
index 6f0cc96..135a92d 100644
--- a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableIterator.kt
+++ b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableIterator.kt
@@ -4,7 +4,8 @@ import co.touchlab.stately.isolate.IsolateState
import co.touchlab.stately.isolate.StateHolder
class IsoMutableIterator internal constructor(stateHolder: StateHolder>) :
- IsolateState>(stateHolder), MutableIterator {
+ IsolateState>(stateHolder),
+ MutableIterator {
override fun hasNext(): Boolean = access { it.hasNext() }
override fun next(): T = access { it.next() }
override fun remove() = access { it.remove() }
diff --git a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableList.kt b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableList.kt
index 8646081..b1fb889 100644
--- a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableList.kt
+++ b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableList.kt
@@ -6,19 +6,20 @@ import co.touchlab.stately.isolate.StateRunner
import co.touchlab.stately.isolate.createState
open class IsoMutableList internal constructor(stateHolder: StateHolder>) :
- IsoMutableCollection(stateHolder), MutableList {
- constructor(stateRunner: StateRunner? = null, producer: () -> MutableList = { mutableListOf() }) : this(createState(stateRunner, producer))
+ IsoMutableCollection(stateHolder),
+ MutableList {
+ constructor(
+ stateRunner: StateRunner? = null,
+ producer: () -> MutableList = { mutableListOf() },
+ ) : this(createState(stateRunner, producer))
override fun get(index: Int): T = asAccess { it.get(index) }
override fun indexOf(element: T): Int = asAccess { it.indexOf(element) }
override fun lastIndexOf(element: T): Int = asAccess { it.lastIndexOf(element) }
override fun add(index: Int, element: T) = asAccess { it.add(index, element) }
- override fun addAll(index: Int, elements: Collection): Boolean =
- asAccess { it.addAll(index, elements) }
- override fun listIterator(): MutableListIterator =
- asAccess { IsoMutableListIterator(fork(it.listIterator())) }
- override fun listIterator(index: Int): MutableListIterator =
- asAccess { IsoMutableListIterator(fork(it.listIterator(index))) }
+ override fun addAll(index: Int, elements: Collection): Boolean = asAccess { it.addAll(index, elements) }
+ override fun listIterator(): MutableListIterator = asAccess { IsoMutableListIterator(fork(it.listIterator())) }
+ override fun listIterator(index: Int): MutableListIterator = asAccess { IsoMutableListIterator(fork(it.listIterator(index))) }
override fun removeAt(index: Int): T = asAccess { it.removeAt(index) }
override fun set(index: Int, element: T): T = asAccess { it.set(index, element) }
override fun subList(fromIndex: Int, toIndex: Int): MutableList = asAccess {
@@ -29,7 +30,8 @@ open class IsoMutableList internal constructor(stateHolder: StateHolder internal constructor(stateHolder: StateHolder>) :
- IsolateState>(stateHolder), MutableListIterator {
+ IsolateState>(stateHolder),
+ MutableListIterator {
override fun hasPrevious(): Boolean = access { it.hasPrevious() }
override fun nextIndex(): Int = access { it.nextIndex() }
override fun previous(): T = access { it.previous() }
diff --git a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableMap.kt b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableMap.kt
index 996b723..74e1e85 100644
--- a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableMap.kt
+++ b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableMap.kt
@@ -5,7 +5,8 @@ import co.touchlab.stately.isolate.StateRunner
import co.touchlab.stately.isolate.createState
open class IsoMutableMap(stateRunner: StateRunner? = null, producer: () -> MutableMap = { mutableMapOf() }) :
- IsolateState>(createState(stateRunner, producer)), MutableMap {
+ IsolateState>(createState(stateRunner, producer)),
+ MutableMap {
override val size: Int
get() = access { it.size }
@@ -28,11 +29,7 @@ open class IsoMutableMap(stateRunner: StateRunner? = null, producer: () ->
override fun putAll(from: Map) = access { it.putAll(from) }
override fun remove(key: K): V? = access { it.remove(key) }
- override fun equals(other: Any?): Boolean {
- return access { it.equals(other) }
- }
+ override fun equals(other: Any?): Boolean = access { it.equals(other) }
- override fun hashCode(): Int {
- return access { it.hashCode() }
- }
+ override fun hashCode(): Int = access { it.hashCode() }
}
diff --git a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableSet.kt b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableSet.kt
index 05a479f..81f00d6 100644
--- a/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableSet.kt
+++ b/deprecated/stately-iso-collections/src/commonMain/kotlin/co/touchlab/stately/collections/IsoMutableSet.kt
@@ -5,6 +5,10 @@ import co.touchlab.stately.isolate.StateRunner
import co.touchlab.stately.isolate.createState
open class IsoMutableSet internal constructor(stateHolder: StateHolder