File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
adapter/src/main/kotlin/org/javacs/ktda/util Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -12,15 +12,15 @@ private data class ObjectMapping<O, V> (
12
12
val value : V
13
13
)
14
14
15
- private var currentID = 1L
16
-
17
15
/* *
18
16
* Maps objects of owners to multiple owned values.
19
17
* To store and retrieve objects, unique ids are used.
20
18
*/
21
19
class ObjectPool <O , V > {
22
20
private val mappingsByID = mutableMapOf<Long , ObjectMapping <O , V >>()
23
21
private val mappingsByOwner = mutableMapOf<O , MutableSet <ObjectMapping <O , V >>>()
22
+
23
+ private var currentID = 1L
24
24
25
25
val empty: Boolean
26
26
get() = mappingsByID.isEmpty()
@@ -76,12 +76,10 @@ class ObjectPool<O, V> {
76
76
fun containsID (id : Long ) = mappingsByID.contains(id)
77
77
78
78
private fun nextID (): Long {
79
- var id = currentID
79
+ do {
80
+ currentID++
81
+ } while (containsID(currentID));
80
82
81
- while (containsID(id)) {
82
- id + = 1
83
- }
84
-
85
- return id
83
+ return currentID
86
84
}
87
85
}
You can’t perform that action at this time.
0 commit comments