diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-11-26 23:12:00 -0800 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-11-26 23:12:00 -0800 |
commit | 33de562b3a224b2b9d7108ba0565c2f9ba57c526 (patch) | |
tree | 7330189317c01d1d9d6ff4b86d8acf56379ab60f /src | |
parent | cb5833414c85a0fff815d5d1cb1d99540341046b (diff) | |
parent | f12bb7bda4cd1e145ab5731ae6728f9e8dd2e54c (diff) | |
download | scala-33de562b3a224b2b9d7108ba0565c2f9ba57c526.tar.gz scala-33de562b3a224b2b9d7108ba0565c2f9ba57c526.tar.bz2 scala-33de562b3a224b2b9d7108ba0565c2f9ba57c526.zip |
Merge pull request #3192 from retronym/ticket/4332
SI-4332 Plugs the gaps in views
Diffstat (limited to 'src')
4 files changed, 38 insertions, 0 deletions
diff --git a/src/library/scala/collection/IterableViewLike.scala b/src/library/scala/collection/IterableViewLike.scala index 236bfd154c..f24b8a075d 100644 --- a/src/library/scala/collection/IterableViewLike.scala +++ b/src/library/scala/collection/IterableViewLike.scala @@ -117,5 +117,14 @@ trait IterableViewLike[+A, override def sliding(size: Int, step: Int): Iterator[This] = self.iterator.sliding(size, step) map (x => newForced(x).asInstanceOf[This]) + override def sliding(size: Int): Iterator[This] = + sliding(size, 1) // we could inherit this, but that implies knowledge of the way the super class is implemented. + + override def dropRight(n: Int): This = + take(thisSeq.length - n) + + override def takeRight(n: Int): This = + drop(thisSeq.length - n) + override def stringPrefix = "IterableView" } diff --git a/src/library/scala/collection/SeqViewLike.scala b/src/library/scala/collection/SeqViewLike.scala index 1194cd7199..a949b56851 100644 --- a/src/library/scala/collection/SeqViewLike.scala +++ b/src/library/scala/collection/SeqViewLike.scala @@ -137,5 +137,20 @@ trait SeqViewLike[+A, override def sorted[B >: A](implicit ord: Ordering[B]): This = newForced(thisSeq sorted ord).asInstanceOf[This] + override def sortWith(lt: (A, A) => Boolean): This = + newForced(thisSeq sortWith lt).asInstanceOf[This] + + override def sortBy[B](f: (A) => B)(implicit ord: Ordering[B]): This = + newForced(thisSeq sortBy f).asInstanceOf[This] + + override def combinations(n: Int): Iterator[This] = + (thisSeq combinations n).map(as => newForced(as).asInstanceOf[This]) + + override def permutations: Iterator[This] = + thisSeq.permutations.map(as => newForced(as).asInstanceOf[This]) + + override def distinct: This = + newForced(thisSeq.distinct).asInstanceOf[This] + override def stringPrefix = "SeqView" } diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala index ca1c450e3f..d56ecb16ed 100644 --- a/src/library/scala/collection/TraversableViewLike.scala +++ b/src/library/scala/collection/TraversableViewLike.scala @@ -209,5 +209,18 @@ trait TraversableViewLike[+A, override def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3)) = (newMapped(x => asTriple(x)._1), newMapped(x => asTriple(x)._2), newMapped(x => asTriple(x)._3)) // TODO - Performance improvements. + override def filterNot(p: (A) => Boolean): This = + newFiltered(a => !(p(a))) + + override def inits: Iterator[This] = + thisSeq.inits.map(as => newForced(as).asInstanceOf[This]) + + override def tails: Iterator[This] = + thisSeq.tails.map(as => newForced(as).asInstanceOf[This]) + + override def tail: This = + // super.tail would also work as it is currently implemented in terms of drop(Int). + if (isEmpty) super.tail else newDropped(1) + override def toString = viewToString } diff --git a/src/library/scala/collection/mutable/IndexedSeqView.scala b/src/library/scala/collection/mutable/IndexedSeqView.scala index 36c1076b87..31a4749960 100644 --- a/src/library/scala/collection/mutable/IndexedSeqView.scala +++ b/src/library/scala/collection/mutable/IndexedSeqView.scala @@ -93,6 +93,7 @@ self => override def span(p: A => Boolean): (This, This) = (newTakenWhile(p), newDroppedWhile(p)) override def splitAt(n: Int): (This, This) = (take(n), drop(n)) // !!! override def reverse: This = newReversed + override def tail: IndexedSeqView[A, Coll] = if (isEmpty) super.tail else slice(1, length) } /** An object containing the necessary implicit definitions to make |