mirror of
https://github.com/tursom/TursomServer.git
synced 2025-04-01 15:11:08 +08:00
添加 clone 库,需要kotlin反射支持
This commit is contained in:
parent
29863cd987
commit
d1baaa2526
@ -1,26 +1,38 @@
|
|||||||
package cn.tursom.core.datastruct
|
package cn.tursom.core.datastruct
|
||||||
|
|
||||||
class SimpHashMap<K, V>(
|
class SimpHashMap<K, V>(
|
||||||
val hashMap: java.util.AbstractMap<K, V> = HashMap()
|
val hashMap: java.util.AbstractMap<K, V> = HashMap()
|
||||||
) : SimpMap<K, V>, Map<K, V> by hashMap {
|
) : SimpMap<K, V>, MutableMap<K, V> by hashMap {
|
||||||
override fun delete(key: K): V? {
|
override fun delete(key: K): V? {
|
||||||
|
return hashMap.remove(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun set(key: K, value: V) {
|
||||||
|
hashMap[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clear() {
|
||||||
|
hashMap.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun first(): V? {
|
||||||
|
val i = hashMap.iterator()
|
||||||
|
return if (i.hasNext()) {
|
||||||
|
i.next().value
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun put(key: K, value: V): V? {
|
||||||
|
return hashMap.put(key, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun putAll(from: Map<out K, V>) {
|
||||||
|
hashMap.putAll(from)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun remove(key: K): V? {
|
||||||
return hashMap.remove(key)
|
return hashMap.remove(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun set(key: K, value: V) {
|
|
||||||
hashMap[key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun clear() {
|
|
||||||
hashMap.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun first(): V? {
|
|
||||||
val i = hashMap.iterator()
|
|
||||||
return if (i.hasNext()) {
|
|
||||||
i.next().value
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user