summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-02-03 17:34:31 +0000
committerPaul Phillips <paulp@improving.org>2010-02-03 17:34:31 +0000
commit96a42a2eda85489bb7dba25d9e8597bd35d7bcbd (patch)
tree51e3848b5d994cdaee75c9faefead41bc9e729d0 /src/library
parenta6eecfb04532c83a715d520e885250e8de808f9e (diff)
downloadscala-96a42a2eda85489bb7dba25d9e8597bd35d7bcbd.tar.gz
scala-96a42a2eda85489bb7dba25d9e8597bd35d7bcbd.tar.bz2
scala-96a42a2eda85489bb7dba25d9e8597bd35d7bcbd.zip
Striking while the iron is hot, renamed removeD...
Striking while the iron is hot, renamed removeDuplicates to unique and deprecated removeDuplicates. The debate between distinct and unique was vigorous but unique won by a freckle. (Dark horse 'nub' was disqualified for taking performance enhancers.) The only thing which might need review is the choice of name, but review by odersky.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/SeqLike.scala2
-rw-r--r--src/library/scala/collection/SeqProxyLike.scala2
-rw-r--r--src/library/scala/collection/immutable/List.scala3
-rw-r--r--src/library/scala/collection/immutable/Stream.scala4
-rw-r--r--src/library/scala/collection/interfaces/SeqMethods.scala2
5 files changed, 8 insertions, 5 deletions
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 5b866e5b3d..b0587b43fa 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -610,7 +610,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
*
* @return A new $coll which contains the first occurrence of every element of this $coll.
*/
- def removeDuplicates: Repr = {
+ def unique: Repr = {
val b = newBuilder
var seen = Set[A]() //TR: should use mutable.HashSet?
for (x <- this) {
diff --git a/src/library/scala/collection/SeqProxyLike.scala b/src/library/scala/collection/SeqProxyLike.scala
index 3dfac63dde..492e16e0b7 100644
--- a/src/library/scala/collection/SeqProxyLike.scala
+++ b/src/library/scala/collection/SeqProxyLike.scala
@@ -50,7 +50,7 @@ trait SeqProxyLike[+A, +This <: SeqLike[A, This] with Seq[A]] extends SeqLike[A,
override def union[B >: A, That](that: Seq[B])(implicit bf: CanBuildFrom[This, B, That]): That = self.union(that)(bf)
override def diff[B >: A, That](that: Seq[B]): This = self.diff(that)
override def intersect[B >: A, That](that: Seq[B]): This = self.intersect(that)
- override def removeDuplicates: This = self.removeDuplicates
+ override def unique: This = self.unique
override def patch[B >: A, That](from: Int, patch: Seq[B], replaced: Int)(implicit bf: CanBuildFrom[This, B, That]): That = self.patch(from, patch, replaced)(bf)
override def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[This, B, That]): That = self.padTo(len, elem)(bf)
override def indices: Range = self.indices
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 415a31a02e..9b95d02b5a 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -288,6 +288,9 @@ sealed abstract class List[+A] extends LinearSeq[A]
b.toList
}
+ @deprecated("use `unique' instead")
+ def removeDuplicates: List[A] = unique
+
/** <p>
* Sort the list according to the comparison function
* `lt(e1: a, e2: a) =&gt; Boolean`,
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 7b9db5e21e..10e60a9417 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -344,9 +344,9 @@ self =>
/** Builds a new stream from this stream in which any duplicates (wrt to ==) removed.
* Among duplicate elements, only the first one is retained in the result stream
*/
- override def removeDuplicates: Stream[A] =
+ override def unique: Stream[A] =
if (isEmpty) this
- else new Stream.Cons(head, tail.filter(head !=).removeDuplicates)
+ else new Stream.Cons(head, tail.filter(head !=).unique)
/** Returns a new sequence of given length containing the elements of this sequence followed by zero
* or more occurrences of given elements.
diff --git a/src/library/scala/collection/interfaces/SeqMethods.scala b/src/library/scala/collection/interfaces/SeqMethods.scala
index df0307174d..2baaee83f7 100644
--- a/src/library/scala/collection/interfaces/SeqMethods.scala
+++ b/src/library/scala/collection/interfaces/SeqMethods.scala
@@ -44,7 +44,7 @@ trait SeqMethods[+A, +This <: SeqLike[A, This] with Seq[A]] extends IterableMeth
def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[This, B, That]): That
def patch[B >: A, That](from: Int, patch: Seq[B], replaced: Int)(implicit bf: CanBuildFrom[This, B, That]): That
def prefixLength(p: A => Boolean): Int
- def removeDuplicates: This
+ def unique: This
def reverse: This
def reverseIterator: Iterator[A]
def segmentLength(p: A => Boolean, from: Int): Int