I need to store values in map likie this:
val map = HashMap<String, Set<String>>()
But it is hard to interact with Set inside the map.
Is there any multimap implementations in Kotlin like Multimap in Google Guava?
You can use the map() function to easily convert a list of one type to a list of another type. It returns a list containing the results of applying the specified transform function to each element in the original list. That's all about conversion between lists of different types in Kotlin.
No, there currently isn't. And there probably won't be one in the future.
Reference: https://discuss.kotlinlang.org/t/the-standard-library-and-a-kotlin-manifesto/1303/6
Alternative:
org.springframework.util.MultiValueMap org.apache.commons.collections4.MultiMap com.google.common.collect.Multimap
To play with the Set
in your example, you can:
map["key"].forEach(::println)
Or something else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With