snackycracky
01/21/2019, 2:57 PMmap
a SortedSet
without transitioning the whole thing to a List
?diesieben07
01/21/2019, 2:58 PMcollection.mapTo(targetCollection) { ... }
diesieben07
01/21/2019, 2:59 PMcollection.mapTo(TreeSet()) { ... }
snackycracky
01/21/2019, 2:59 PMdiesieben07
01/21/2019, 3:04 PMmap
would preserve it, too (by adding to a list). When using mapTo
the resulting order depends on the collection you are mapping to. If you are mapping to a HashSet
for example you won't get any ordering guarantees.diesieben07
01/21/2019, 3:05 PMLinkedHashSet
you will get same order as source.diesieben07
01/21/2019, 3:05 PMTreeSet
you will get order based on comparing entriessnackycracky
01/21/2019, 3:08 PMApplies the given transform function to each element of the original collection and appends the results to the given destination.
so I would assume a treeset would preserve the comparator I provided…snackycracky
01/21/2019, 3:08 PMdiesieben07
01/21/2019, 3:09 PMmapTo
will iterate through your source collection and add the mapped element to the LinkedHashSetdiesieben07
01/21/2019, 3:09 PMsnackycracky
01/21/2019, 3:10 PMdiesieben07
01/21/2019, 3:10 PMdiesieben07
01/21/2019, 3:10 PMsnackycracky
01/21/2019, 3:11 PMAlowaniak
01/21/2019, 3:28 PM