diff options
Diffstat (limited to 'src/library')
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 |