From c3bddc74e4c54a6700b98b9b0bb17f4897e7972d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 3 Jun 2009 20:38:24 +0000 Subject: Added the much clamored for toSet to Traversable. performance love, but then it has a lot of company in that regard. --- src/library/scala/collection/generic/TraversableTemplate.scala | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/collection/generic/TraversableTemplate.scala b/src/library/scala/collection/generic/TraversableTemplate.scala index 09396ef3dc..f7b6dcc740 100644 --- a/src/library/scala/collection/generic/TraversableTemplate.scala +++ b/src/library/scala/collection/generic/TraversableTemplate.scala @@ -673,6 +673,10 @@ self => */ def toStream: Stream[A] = toList.toStream + /** Returns a set with all unique elements in this traversable object. + */ + def toSet[B >: A]: Set[B] = Set() ++ thisCollection + /** Sort the traversable according to the comparison function * <(e1: a, e2: a) => Boolean, * which should be true iff e1 is smaller than -- cgit v1.2.3