better impl of get(key)

master
Robinson 2023-08-04 20:26:54 -06:00
parent 96d27cde62
commit 2f60a33ef0
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
1 changed files with 15 additions and 1 deletions

View File

@ -210,7 +210,21 @@ class ArrayMap<K: Any, V> : MutableMap<K, V?>{
* .equals() comparison of each key in reverse order until the specified key is found.
*/
override operator fun get(key: K): V? {
return get(key, null)
val keys = keyTable
var i = size_ - 1
if (key == null) {
while (i >= 0) {
if (keys[i] === key) return valueTable[i]!!
i--
}
}
else {
while (i >= 0) {
if (key == keys[i]) return valueTable[i]!!
i--
}
}
return null
}
/**