Use LinkedHashMap everywhere to preserve order.

This commit is contained in:
Ilya Ryzhenkov
2014-06-11 18:10:46 +04:00
parent cb17f0c635
commit a9da7cfeea
8 changed files with 57 additions and 66 deletions
@@ -184,7 +184,7 @@ fun mapping(): List<GenericFunction> {
doc { "Returns a map of the elements in original collection grouped by the result of given *toKey* function" }
typeParam("K")
returns("Map<K, List<T>>")
body { "return groupByTo(HashMap<K, MutableList<T>>(), toKey)" }
body { "return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey)" }
}
templates add f("groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K)") {
@@ -117,7 +117,7 @@ fun snapshots(): List<GenericFunction> {
returns("Map<K, T>")
body {
"""
val result = HashMap<K, T>()
val result = LinkedHashMap<K, T>()
for (element in this) {
result.put(selector(element), element)
}