Skip to content

Commit 962b57d

Browse files
committed
Share MutabilityOwnership class between collection implementations
1 parent 239a63e commit 962b57d

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

kotlinx-collections-immutable/src/main/kotlin/kotlinx/collections/immutable/implementations/immutableList/PersistentVectorBuilder.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ package kotlinx.collections.immutable.implementations.immutableList
1919
import kotlinx.collections.immutable.PersistentList
2020
import kotlinx.collections.immutable.internal.ListImplementation.checkElementIndex
2121
import kotlinx.collections.immutable.internal.ListImplementation.checkPositionIndex
22-
23-
private class MutabilityOwnership // TODO: Rename to MutabilityOwnership?
22+
import kotlinx.collections.immutable.internal.MutabilityOwnership
2423

2524
class PersistentVectorBuilder<E>(private var vector: PersistentList<E>,
2625
private var vectorRoot: Array<Any?>?,

kotlinx-collections-immutable/src/main/kotlin/kotlinx/collections/immutable/implementations/immutableMap/PersistentHashMapBuilder.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
package kotlinx.collections.immutable.implementations.immutableMap
1818

1919
import kotlinx.collections.immutable.PersistentMap
20-
21-
internal class MutabilityOwnership
20+
import kotlinx.collections.immutable.internal.MutabilityOwnership
2221

2322
internal class PersistentHashMapBuilder<K, V>(private var map: PersistentHashMap<K, V>) : PersistentMap.Builder<K, V>, AbstractMutableMap<K, V>() {
2423
internal var ownership = MutabilityOwnership()

kotlinx-collections-immutable/src/main/kotlin/kotlinx/collections/immutable/implementations/immutableMap/TrieNode.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package kotlinx.collections.immutable.implementations.immutableMap
1818

19+
import kotlinx.collections.immutable.internal.MutabilityOwnership
20+
1921

2022
internal const val MAX_BRANCHING_FACTOR = 32
2123
internal const val LOG_MAX_BRANCHING_FACTOR = 5

kotlinx-collections-immutable/src/main/kotlin/kotlinx/collections/immutable/implementations/immutableSet/PersistentHashSetBuilder.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
package kotlinx.collections.immutable.implementations.immutableSet
1818

1919
import kotlinx.collections.immutable.PersistentSet
20-
21-
internal class MutabilityOwnership
20+
import kotlinx.collections.immutable.internal.MutabilityOwnership
2221

2322
internal class PersistentHashSetBuilder<E>(private var set: PersistentHashSet<E>) : AbstractMutableSet<E>(), PersistentSet.Builder<E> {
2423
internal var ownership = MutabilityOwnership()

kotlinx-collections-immutable/src/main/kotlin/kotlinx/collections/immutable/implementations/immutableSet/TrieNode.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package kotlinx.collections.immutable.implementations.immutableSet
1818

19+
import kotlinx.collections.immutable.internal.MutabilityOwnership
20+
1921

2022
internal const val MAX_BRANCHING_FACTOR = 32
2123
internal const val LOG_MAX_BRANCHING_FACTOR = 5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2016-2019 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package kotlinx.collections.immutable.internal
18+
19+
/**
20+
* The mutability ownership token of a persistent collection builder.
21+
*
22+
* Used to mark persistent data structures, that are owned by a collection builder and can be mutated by it.
23+
*/
24+
internal class MutabilityOwnership

0 commit comments

Comments
 (0)