@@ -84,7 +84,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
84
84
protected [this ] def fromSpecificIterable (coll : Iterable [A ]): C
85
85
86
86
/** Similar to `fromSpecificIterable`, but for a (possibly) different type of element.
87
- * Note that the return type is know `CC[E]`.
87
+ * Note that the return type is now `CC[E]`.
88
88
*/
89
89
@ `inline` final protected [this ] def fromIterable [E ](it : Iterable [E ]): CC [E ] = iterableFactory.from(it)
90
90
@@ -711,15 +711,15 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
711
711
* @return a new $coll consisting of all elements of this $coll that satisfy the given
712
712
* predicate `pred`. Their order may not be preserved.
713
713
*/
714
- def filter (pred : A => Boolean ): C = fromSpecificIterable(new View .Filter (toIterable , pred, isFlipped = false ))
714
+ def filter (pred : A => Boolean ): C = fromSpecificIterable(new View .Filter (this , pred, isFlipped = false ))
715
715
716
716
/** Selects all elements of this $coll which do not satisfy a predicate.
717
717
*
718
718
* @param pred the predicate used to test elements.
719
719
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
720
720
* predicate `pred`. Their order may not be preserved.
721
721
*/
722
- def filterNot (pred : A => Boolean ): C = fromSpecificIterable(new View .Filter (toIterable , pred, isFlipped = true ))
722
+ def filterNot (pred : A => Boolean ): C = fromSpecificIterable(new View .Filter (this , pred, isFlipped = true ))
723
723
724
724
/** Creates a non-strict filter of this $coll.
725
725
*
@@ -744,7 +744,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
744
744
*/
745
745
class WithFilter (p : A => Boolean ) extends collection.WithFilter [A , CC ] {
746
746
747
- protected [this ] def filtered = new View .Filter (toIterable , p, isFlipped = false )
747
+ protected [this ] def filtered = new View .Filter (IterableOps . this , p, isFlipped = false )
748
748
749
749
def map [B ](f : A => B ): CC [B ] = iterableFactory.from(new View .Map (filtered, f))
750
750
@@ -764,7 +764,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
764
764
* which requires only a single traversal.
765
765
*/
766
766
def partition (p : A => Boolean ): (C , C ) = {
767
- val pn = new View .Partition (toIterable , p)
767
+ val pn = new View .Partition (this , p)
768
768
(fromSpecificIterable(pn.first), fromSpecificIterable(pn.second))
769
769
}
770
770
@@ -780,7 +780,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
780
780
def splitAt (n : Int ): (C , C ) = (take(n), drop(n))
781
781
782
782
/** A collection containing the first `n` elements of this collection. */
783
- def take (n : Int ): C = fromSpecificIterable(new View .Take (toIterable , n))
783
+ def take (n : Int ): C = fromSpecificIterable(new View .Take (this , n))
784
784
785
785
/** A collection containing the last `n` elements of this collection. */
786
786
def takeRight (n : Int ): C = {
@@ -802,7 +802,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
802
802
* @return the longest prefix of this $coll whose elements all satisfy
803
803
* the predicate `p`.
804
804
*/
805
- def takeWhile (p : A => Boolean ): C = fromSpecificIterable(new View .TakeWhile (toIterable , p))
805
+ def takeWhile (p : A => Boolean ): C = fromSpecificIterable(new View .TakeWhile (this , p))
806
806
807
807
/** Splits this $coll into a prefix/suffix pair according to a predicate.
808
808
*
@@ -820,7 +820,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
820
820
/** The rest of the collection without its `n` first elements. For
821
821
* linear, immutable collections this should avoid making a copy.
822
822
*/
823
- def drop (n : Int ): C = fromSpecificIterable(new View .Drop (toIterable , n))
823
+ def drop (n : Int ): C = fromSpecificIterable(new View .Drop (this , n))
824
824
825
825
/** The rest of the collection without its `n` last elements. For
826
826
* linear, immutable collections this should avoid making a copy.
@@ -843,7 +843,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
843
843
* @return the longest suffix of this $coll whose first element
844
844
* does not satisfy the predicate `p`.
845
845
*/
846
- def dropWhile (p : A => Boolean ): C = fromSpecificIterable(new View .DropWhile (toIterable , p))
846
+ def dropWhile (p : A => Boolean ): C = fromSpecificIterable(new View .DropWhile (this , p))
847
847
848
848
/** Partitions elements in fixed size ${coll}s.
849
849
* @see [[scala.collection.Iterator ]], method `grouped`
@@ -907,7 +907,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
907
907
* of this $coll.
908
908
*/
909
909
def slice (from : Int , until : Int ): C =
910
- fromSpecificIterable(new View .Drop (new View .Take (toIterable , until), from))
910
+ fromSpecificIterable(new View .Drop (new View .Take (this , until), from))
911
911
912
912
/** Partitions this $coll into a map of ${coll}s according to some discriminator function.
913
913
*
@@ -1022,7 +1022,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1022
1022
* @param op the binary operator applied to the intermediate result and the element
1023
1023
* @return collection with intermediate results
1024
1024
*/
1025
- def scanLeft [B ](z : B )(op : (B , A ) => B ): CC [B ] = fromIterable(new View .ScanLeft (toIterable , z, op))
1025
+ def scanLeft [B ](z : B )(op : (B , A ) => B ): CC [B ] = fromIterable(new View .ScanLeft (this , z, op))
1026
1026
1027
1027
/** Produces a collection containing cumulative results of applying the operator going right to left.
1028
1028
* The head of the collection is the last cumulative result.
@@ -1056,7 +1056,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1056
1056
* @return a new $coll resulting from applying the given function
1057
1057
* `f` to each element of this $coll and collecting the results.
1058
1058
*/
1059
- def map [B ](f : A => B ): CC [B ] = fromIterable(new View .Map (toIterable , f))
1059
+ def map [B ](f : A => B ): CC [B ] = fromIterable(new View .Map (this , f))
1060
1060
1061
1061
/** Builds a new collection by applying a function to all elements of this $coll
1062
1062
* and using the elements of the resulting collections.
@@ -1089,7 +1089,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1089
1089
* @return a new $coll resulting from applying the given collection-valued function
1090
1090
* `f` to each element of this $coll and concatenating the results.
1091
1091
*/
1092
- def flatMap [B ](f : A => IterableOnce [B ]): CC [B ] = fromIterable(new View .FlatMap (toIterable , f))
1092
+ def flatMap [B ](f : A => IterableOnce [B ]): CC [B ] = fromIterable(new View .FlatMap (this , f))
1093
1093
1094
1094
/** Converts this $coll of traversable collections into
1095
1095
* a $coll formed by the elements of these traversable
@@ -1119,7 +1119,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1119
1119
*
1120
1120
*/
1121
1121
def flatten [B ](implicit asIterable : A => IterableOnce [B ]): CC [B ] =
1122
- fromIterable(new View .FlatMap (toIterable , asIterable))
1122
+ fromIterable(new View .FlatMap (this , asIterable))
1123
1123
1124
1124
/** Builds a new collection by applying a partial function to all elements of this $coll
1125
1125
* on which the function is defined.
@@ -1159,7 +1159,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1159
1159
* @return a new $coll which contains all elements
1160
1160
* of this $coll followed by all elements of `suffix`.
1161
1161
*/
1162
- def concat [B >: A ](suffix : Iterable [B ]): CC [B ] = fromIterable(new View .Concat (toIterable , suffix))
1162
+ def concat [B >: A ](suffix : Iterable [B ]): CC [B ] = fromIterable(new View .Concat (this , suffix))
1163
1163
1164
1164
/** Alias for `concat` */
1165
1165
@ `inline` final def ++ [B >: A ](suffix : Iterable [B ]): CC [B ] = concat(suffix)
@@ -1173,7 +1173,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1173
1173
* @return a new $coll containing pairs consisting of corresponding elements of this $coll and `that`.
1174
1174
* The length of the returned collection is the minimum of the lengths of this $coll and `that`.
1175
1175
*/
1176
- def zip [B ](that : Iterable [B ]): CC [(A @ uncheckedVariance, B )] = fromIterable(new View .Zip (toIterable , that))
1176
+ def zip [B ](that : Iterable [B ]): CC [(A @ uncheckedVariance, B )] = fromIterable(new View .Zip (this , that))
1177
1177
// sound bcs of VarianceNote
1178
1178
1179
1179
/** Zips this $coll with its indices.
@@ -1183,7 +1183,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1183
1183
* @example
1184
1184
* `List("a", "b", "c").zipWithIndex == List(("a", 0), ("b", 1), ("c", 2))`
1185
1185
*/
1186
- def zipWithIndex : CC [(A @ uncheckedVariance, Int )] = fromIterable(new View .ZipWithIndex (toIterable ))
1186
+ def zipWithIndex : CC [(A @ uncheckedVariance, Int )] = fromIterable(new View .ZipWithIndex (this ))
1187
1187
1188
1188
/** Returns a $coll formed from this $coll and another iterable collection
1189
1189
* by combining corresponding elements in pairs.
@@ -1199,7 +1199,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1199
1199
* If this $coll is shorter than `that`, `thisElem` values are used to pad the result.
1200
1200
* If `that` is shorter than this $coll, `thatElem` values are used to pad the result.
1201
1201
*/
1202
- def zipAll [A1 >: A , B ](that : Iterable [B ], thisElem : A1 , thatElem : B ): CC [(A1 , B )] = fromIterable(new View .ZipAll (toIterable , that, thisElem, thatElem))
1202
+ def zipAll [A1 >: A , B ](that : Iterable [B ], thisElem : A1 , thatElem : B ): CC [(A1 , B )] = fromIterable(new View .ZipAll (this , that, thisElem, thatElem))
1203
1203
1204
1204
/** Converts this $coll of pairs into two collections of the first and second
1205
1205
* half of each pair.
@@ -1221,7 +1221,7 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] {
1221
1221
* half of each element pair of this $coll.
1222
1222
*/
1223
1223
def unzip [A1 , A2 ](implicit asPair : A => (A1 , A2 )): (CC [A1 ], CC [A2 ]) = {
1224
- val unzipped = new View .Unzip (toIterable )
1224
+ val unzipped = new View .Unzip (this )
1225
1225
(fromIterable(unzipped.first), fromIterable(unzipped.second))
1226
1226
}
1227
1227
0 commit comments