Suppressed unchecked cast where appropriate

master
Robinson 2023-11-29 12:05:43 +01:00
parent 493b6baa7a
commit a13ffe4472
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
12 changed files with 17 additions and 1 deletions

View File

@ -205,6 +205,7 @@ class LockFreeArrayList<E> : MutableList<E>, RandomAccess, Cloneable, Serializab
* Return a non-thread-safe copy of the backing array
*/
fun toList(): ArrayList<E> {
@Suppress("UNCHECKED_CAST")
return ArrayList(listRef[this] as ArrayList<E>)
}

View File

@ -415,6 +415,7 @@ class LockFreeBiMap<K: Any, V: Any> : MutableMap<K, V>, Cloneable, Serializable
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): MutableMap<K, V> {
@Suppress("UNCHECKED_CAST")
return HashMap(forwardREF[this] as MutableMap<K, V>)
}
@ -422,6 +423,7 @@ class LockFreeBiMap<K: Any, V: Any> : MutableMap<K, V>, Cloneable, Serializable
* Return a non-thread-safe copy of the backing map
*/
fun toReverseMap(): MutableMap<V, K> {
@Suppress("UNCHECKED_CAST")
return HashMap(reverseREF[this] as MutableMap<V, K>)
}

View File

@ -197,6 +197,7 @@ class LockFreeHashMap<K: Any, V> : MutableMap<K, V>, Cloneable, Serializable {
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): HashMap<K, V> {
@Suppress("UNCHECKED_CAST")
return HashMap(mapREF[this] as HashMap<K, V>)
}

View File

@ -129,6 +129,7 @@ class LockFreeHashSet<E> : MutableSet<E>, Cloneable, Serializable {
* Return a non-thread-safe copy of the backing set
*/
fun toSet(): HashSet<E> {
@Suppress("UNCHECKED_CAST")
return HashSet(setREF[this] as HashSet<E>)
}

View File

@ -426,6 +426,7 @@ class LockFreeIntBiMap<V: Any> : MutableMap<Int, V>, Cloneable, Serializable {
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): IntMap<V> {
@Suppress("UNCHECKED_CAST")
return IntMap(forwardREF[this] as IntMap<V>)
}
@ -433,6 +434,7 @@ class LockFreeIntBiMap<V: Any> : MutableMap<Int, V>, Cloneable, Serializable {
* Return a non-thread-safe copy of the backing reverse-map
*/
fun toReverseMap(): ObjectIntMap<V> {
@Suppress("UNCHECKED_CAST")
return ObjectIntMap(reverseREF[this] as ObjectIntMap<V>)
}

View File

@ -217,6 +217,7 @@ class LockFreeIntMap<V> : MutableMap<Int, V>, Cloneable, Serializable {
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): IntMap<V> {
@Suppress("UNCHECKED_CAST")
return IntMap(mapREF[this] as IntMap<V>)
}

View File

@ -202,6 +202,7 @@ class LockFreeIntStringMap : MutableMap<Int, String?>, Cloneable, Serializable {
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): IntMap<String?> {
@Suppress("UNCHECKED_CAST")
return IntMap(mapREF[this] as IntMap<String?>)
}

View File

@ -218,6 +218,7 @@ class LockFreeLongMap<V> : MutableMap<Long, V>, Cloneable, Serializable {
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): LongMap<V> {
@Suppress("UNCHECKED_CAST")
return LongMap(mapREF[this] as LongMap<V>)
}

View File

@ -422,6 +422,7 @@ class LockFreeObjectBiMap<K: Any, V: Any> : MutableMap<K, V>, Cloneable, Seriali
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): ObjectMap<K, V> {
@Suppress("UNCHECKED_CAST")
return ObjectMap(forwardREF[this] as ObjectMap<K, V>)
}
@ -429,6 +430,7 @@ class LockFreeObjectBiMap<K: Any, V: Any> : MutableMap<K, V>, Cloneable, Seriali
* Return a non-thread-safe copy of the backing reverse-map
*/
fun toReverseMap(): ObjectMap<V, K> {
@Suppress("UNCHECKED_CAST")
return ObjectMap(reverseREF[this] as ObjectMap<V, K>)
}

View File

@ -208,7 +208,7 @@ class LockFreeObjectIntBiMap<K: Any> : MutableMap<K, Int>, Cloneable, Serializab
*/
@Synchronized
fun putForce(key: K, value: Int): Int {
val prevForwardValue = forwardHashMap[key, defaultReturnValue]!!
val prevForwardValue = forwardHashMap[key, defaultReturnValue]
forwardHashMap.put(key, value)
if (prevForwardValue != defaultReturnValue) {
reverseHashMap.remove(prevForwardValue)
@ -433,6 +433,7 @@ class LockFreeObjectIntBiMap<K: Any> : MutableMap<K, Int>, Cloneable, Serializab
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): ObjectIntMap<K> {
@Suppress("UNCHECKED_CAST")
return ObjectIntMap(forwardREF[this] as ObjectIntMap<K>)
}
@ -440,6 +441,7 @@ class LockFreeObjectIntBiMap<K: Any> : MutableMap<K, Int>, Cloneable, Serializab
* Return a non-thread-safe copy of the backing reverse-map
*/
fun toReverseMap(): IntMap<K> {
@Suppress("UNCHECKED_CAST")
return IntMap(reverseREF[this] as IntMap<K>)
}

View File

@ -214,6 +214,7 @@ class LockFreeObjectIntMap<K: Any> : MutableMap<K, Int>, Cloneable, Serializable
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): ObjectIntMap<K> {
@Suppress("UNCHECKED_CAST")
return ObjectIntMap(mapREF[this] as ObjectIntMap<K>)
}

View File

@ -221,6 +221,7 @@ class LockFreeObjectMap<K: Any, V> : MutableMap<K, V>, Cloneable, Serializable {
* Return a non-thread-safe copy of the backing map
*/
fun toMap(): ObjectMap<K, V> {
@Suppress("UNCHECKED_CAST")
return ObjectMap(mapREF[this] as ObjectMap<K, V>)
}