Use LinkedHashMap in DynamicSynchableGroup so iteration order is preserved
This commit is contained in:
parent
d35da8c7f4
commit
a54382b74e
@ -190,7 +190,7 @@ class DynamicSynchableGroup<T : Any>(
|
|||||||
private data class Slot<T : Any>(val value: T, val id: Int)
|
private data class Slot<T : Any>(val value: T, val id: Int)
|
||||||
|
|
||||||
private val remoteStates = ArrayList<RemoteState>()
|
private val remoteStates = ArrayList<RemoteState>()
|
||||||
private val value2slot = HashMap<T, Slot<T>>()
|
private val value2slot = LinkedHashMap<T, Slot<T>>()
|
||||||
private val id2slot = Int2ObjectOpenHashMap<Slot<T>>()
|
private val id2slot = Int2ObjectOpenHashMap<Slot<T>>()
|
||||||
private val idAllocator = IDAllocator()
|
private val idAllocator = IDAllocator()
|
||||||
|
|
||||||
@ -323,11 +323,7 @@ class DynamicSynchableGroup<T : Any>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun remove(element: T): Boolean {
|
override fun remove(element: T): Boolean {
|
||||||
if (element !in value2slot) {
|
val slot = value2slot.remove(element) ?: return false
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
val slot = value2slot.remove(element)!!
|
|
||||||
checkNotNull(id2slot.remove(slot.id))
|
checkNotNull(id2slot.remove(slot.id))
|
||||||
remoteStates.forEach { it.remove(slot) }
|
remoteStates.forEach { it.remove(slot) }
|
||||||
idAllocator.release(slot.id)
|
idAllocator.release(slot.id)
|
||||||
|
Loading…
Reference in New Issue
Block a user