Add toList() operation on Maps

This commit is contained in:
Ilya Ryzhenkov
2014-04-15 16:42:55 +04:00
committed by Andrey Breslav
parent 5537ff5f3c
commit 118126c744
2 changed files with 24 additions and 0 deletions
@@ -397,6 +397,16 @@ public fun String.toLinkedList(): LinkedList<Char> {
return toCollection(LinkedList<Char>())
}
/**
* Returns a List containing all key-value pairs
*/
public fun <K, V> Map<K, V>.toList(): List<Map.Entry<K, V>> {
val result = ArrayList<Map.Entry<K, V>>(size)
for (item in this)
result.add(item)
return result
}
/**
* Returns a List containing all elements
*/