swapKeys

fun <K1, K2, V> Map<K1, Map<K2, V>>.swapKeys(): Map<K2, Map<K1, V>>

Swaps dimensions in two-dimensional map. The returned map has keys from the second dimension as primary keys and primary keys are used in the second dimension.


inline fun <K1, K2, K3, KR1, KR2, KR3, V> Map<K1, Map<K2, Map<K3, V>>>.swapKeys(transform: (K1, K2, K3) -> Triple<KR1, KR2, KR3>): Map<KR1, Map<KR2, Map<KR3, V>>>

Works similarly as swapKeys but the final map has three levels. transform specifies how the keys should be swapped (or modified) in the newly created map.

Sources

Link copied to clipboard
Link copied to clipboard