diff options
author | Paul Phillips <paulp@improving.org> | 2010-10-27 22:50:40 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-10-27 22:50:40 +0000 |
commit | 6e6435156afeea32a02e13ff7e6b66e54d7575c5 (patch) | |
tree | b8814a48af7366f0d0f4a55ea5c8f391fd234a6b /src/library | |
parent | 683af5895e3dead6a6dac3c9939a7bcd2c7bad18 (diff) | |
download | scala-6e6435156afeea32a02e13ff7e6b66e54d7575c5.tar.gz scala-6e6435156afeea32a02e13ff7e6b66e54d7575c5.tar.bz2 scala-6e6435156afeea32a02e13ff7e6b66e54d7575c5.zip |
Some issues with Tuple2/3.
foreach method in Tuple3, and both classes have what is now a redundant
zip method which is also unfortunately completely strict in a not
entirely fixable fashion. So "zip" is deprecated in favor of zipped.
Closes #3526, but the code which closes that is primarily found in
r23228. No review.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Tuple2.scala | 17 | ||||
-rw-r--r-- | src/library/scala/Tuple3.scala | 33 |
2 files changed, 8 insertions, 42 deletions
diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala index 1050fa26fa..50d584f3b8 100644 --- a/src/library/scala/Tuple2.scala +++ b/src/library/scala/Tuple2.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// generated by genprod on Sat Oct 16 11:19:09 PDT 2010 (with extra methods) +// generated by genprod on Wed Oct 27 14:26:15 PDT 2010 (with extra methods) package scala @@ -27,22 +27,11 @@ case class Tuple2[@specialized(Int, Long, Double) +T1, @specialized(Int, Long, D /** Swap the elements of the tuple */ def swap: Tuple2[T2,T1] = Tuple2(_2, _1) + @deprecated("Use `zipped` instead.") def zip[Repr1, El1, El2, To](implicit w1: T1 => TLike[El1, Repr1], w2: T2 => Iterable[El2], cbf1: CBF[Repr1, (El1, El2), To]): To = { - val coll1: TLike[El1, Repr1] = _1 - val coll2: Iterable[El2] = _2 - val b1 = cbf1(coll1.repr) - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) - b1 += ((el1, elems2.next)) - else - return b1.result - } - - b1.result + zipped map ((x, y) => ((x, y))) } /** Wraps a tuple in a `Zipped`, which supports 2-ary generalisations of map, flatMap, filter,... diff --git a/src/library/scala/Tuple3.scala b/src/library/scala/Tuple3.scala index bd77157d05..abd47a59b9 100644 --- a/src/library/scala/Tuple3.scala +++ b/src/library/scala/Tuple3.scala @@ -6,7 +6,7 @@ ** |/ ** \* */ -// generated by genprod on Sat Oct 16 11:19:09 PDT 2010 (with extra methods) +// generated by genprod on Wed Oct 27 14:26:15 PDT 2010 (with extra methods) package scala @@ -24,25 +24,13 @@ case class Tuple3[+T1, +T2, +T3](_1:T1,_2:T2,_3:T3) { override def toString() = "(" + _1 + "," + _2 + "," + _3 + ")" + + @deprecated("Use `zipped` instead.") def zip[Repr1, El1, El2, El3, To](implicit w1: T1 => TLike[El1, Repr1], w2: T2 => Iterable[El2], w3: T3 => Iterable[El3], cbf1: CBF[Repr1, (El1, El2, El3), To]): To = { - val coll1: TLike[El1, Repr1] = _1 - val coll2: Iterable[El2] = _2 - val coll3: Iterable[El3] = _3 - val b1 = cbf1(coll1.repr) - val elems2 = coll2.iterator - val elems3 = coll3.iterator - - for (el1 <- coll1) { - if (elems2.hasNext && elems3.hasNext) - b1 += ((el1, elems2.next, elems3.next)) - else - return b1.result - } - - b1.result + zipped map ((x, y, z) => ((x, y, z))) } /** Wraps a tuple in a `Zipped`, which supports 3-ary generalisations of map, flatMap, filter,... @@ -97,7 +85,7 @@ case class Tuple3[+T1, +T2, +T3](_1:T1,_2:T2,_3:T3) val elems3 = coll3.iterator def result = (b1.result, b2.result, b3.result) - for(el1 <- coll1) { + for (el1 <- coll1) { if (elems2.hasNext && elems3.hasNext) { val el2 = elems2.next val el3 = elems3.next @@ -131,17 +119,6 @@ case class Tuple3[+T1, +T2, +T3](_1:T1,_2:T2,_3:T3) def forall(f: (El1, El2, El3) => Boolean): Boolean = !exists((x, y, z) => !f(x, y, z)) - def foreach[U](f: (El1, El2) => U): Unit = { - val elems2 = coll2.iterator - - for (el1 <- coll1) { - if (elems2.hasNext) - f(el1, elems2.next) - else - return - } - } - def foreach[U](f: (El1, El2, El3) => U): Unit = { val elems2 = coll2.iterator val elems3 = coll3.iterator |