com.daodecode.scalax.collection.extensions
Builds a new collection from this collection without any duplicate elements (as
determined by ==
after applying transforming function f
).
Builds a new collection from this collection without any duplicate elements (as
determined by ==
after applying transforming function f
).
Function takeFirst
defines which of duplicates will be preserved.
If it returns true
first of compared duplicates will be kept, second one otherwise.
Example:
scala> val xs = List(1 -> "one", 1 -> "ten", 2 -> "two", 2 -> "twenty"). | distinctBy(_._1, takeFirst = _._2.length > _._2.length) xs: List[(Int, String)] = List((1,ten), (2,twenty))
A new collection which contains selected occurrence of every element of this collection.
0.1.1
Builds a new collection from this collection without any duplicate elements (as
determined by ==
after applying transforming function f
).
Builds a new collection from this collection without any duplicate elements (as
determined by ==
after applying transforming function f
).
First of all the duplicates is preserved
Example:
scala> val xs = List(1 -> "one", 1 -> "ten", 2 -> "two", 2 -> "twenty").distinctBy(_._1) xs: List[(Int, String)] = List((1,one), (2,two))
A new collection which contains the first occurrence of every element of this collection.
0.1.0