I have HashMap
in Kotlin
val map = HashMap<String, String>()
I want to know how to get key for a particular value from this HashMap
without iterating through complete HashMap
?
Using filterValues {}
val map = HashMap<String, String>()
val keys = map.filterValues { it == "your_value" }.keys
And keys
will be the set of all keys matching the given value