@@ -127,7 +127,7 @@ trait Iterable[+A] extends IterableOnce[A]
127
127
* @define willNotTerminateInf
128
128
*
129
129
* Note: will not terminate for infinite-sized collections.
130
- * @define undefinedorder
130
+ * @define undefinedorder
131
131
* The order in which operations are performed on elements is unspecified
132
132
* and may be nondeterministic.
133
133
*/
@@ -140,9 +140,9 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
140
140
def toIterable : Iterable [A ]
141
141
142
142
/** Converts this $coll to an unspecified Iterable. Will return
143
- * the same collection if this instance is already Iterable.
144
- * @return An Iterable containing all elements of this $coll.
145
- */
143
+ * the same collection if this instance is already Iterable.
144
+ * @return An Iterable containing all elements of this $coll.
145
+ */
146
146
@ deprecated(" toTraversable is internal and will be made protected; its name is similar to `toList` or `toSeq`, but it doesn't copy non-immutable collections" , " 2.13.0" )
147
147
final def toTraversable : Traversable [A ] = toIterable
148
148
@@ -208,24 +208,24 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
208
208
*/
209
209
protected def newSpecificBuilder : Builder [A @ uncheckedVariance, C ]
210
210
211
- /** The empty iterable of the same type as this iterable .
211
+ /** The empty $coll .
212
212
*
213
- * @return an empty iterable of type `C` .
213
+ * @return an empty iterable of type $Coll .
214
214
*/
215
215
def empty : C = fromSpecific(Nil )
216
216
217
217
/** Selects the first element of this $coll.
218
- * $orderDependent
219
- * @return the first element of this $coll.
220
- * @throws NoSuchElementException if the $coll is empty.
221
- */
218
+ * $orderDependent
219
+ * @return the first element of this $coll.
220
+ * @throws NoSuchElementException if the $coll is empty.
221
+ */
222
222
def head : A = iterator.next()
223
223
224
224
/** Optionally selects the first element.
225
- * $orderDependent
226
- * @return the first element of this $coll if it is nonempty,
227
- * `None` if it is empty.
228
- */
225
+ * $orderDependent
226
+ * @return the first element of this $coll if it is nonempty,
227
+ * `None` if it is empty.
228
+ */
229
229
def headOption : Option [A ] = {
230
230
val it = iterator
231
231
if (it.hasNext) Some (it.next()) else None
@@ -244,32 +244,32 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
244
244
}
245
245
246
246
/** Optionally selects the last element.
247
- * $orderDependent
248
- * @return the last element of this $coll$ if it is nonempty,
249
- * `None` if it is empty.
250
- */
247
+ * $orderDependent
248
+ * @return the last element of this $coll if it is nonempty,
249
+ * `None` if it is empty.
250
+ */
251
251
def lastOption : Option [A ] = if (isEmpty) None else Some (last)
252
252
253
253
/** A view over the elements of this collection. */
254
254
def view : View [A ] = View .fromIteratorProvider(() => iterator)
255
255
256
256
/** Compares the size of this $coll to a test value.
257
- *
258
- * @param otherSize the test value that gets compared with the size.
259
- * @return A value `x` where
260
- * {{{
261
- * x < 0 if this.size < otherSize
262
- * x == 0 if this.size == otherSize
263
- * x > 0 if this.size > otherSize
264
- * }}}
265
- *
266
- * The method as implemented here does not call `size` directly; its running time
267
- * is `O(size min otherSize)` instead of `O(size)`. The method should be overridden
268
- * if computing `size` is cheap and `knownSize` returns `-1`.
269
- *
270
- * @see [[sizeIs ]]
271
- */
272
- def sizeCompare (otherSize : Int ): Int = {
257
+ *
258
+ * @param otherSize the test value that gets compared with the size.
259
+ * @return A value `x` where
260
+ * {{{
261
+ * x < 0 if this.size < otherSize
262
+ * x == 0 if this.size == otherSize
263
+ * x > 0 if this.size > otherSize
264
+ * }}}
265
+ *
266
+ * The method as implemented here does not call `size` directly; its running time
267
+ * is `O(size min otherSize)` instead of `O(size)`. The method should be overridden
268
+ * if computing `size` is cheap and `knownSize` returns `-1`.
269
+ *
270
+ * @see [[sizeIs ]]
271
+ */
272
+ def sizeCompare (otherSize : Int ): Int =
273
273
if (otherSize < 0 ) 1
274
274
else {
275
275
val known = knownSize
@@ -285,7 +285,6 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
285
285
i - otherSize
286
286
}
287
287
}
288
- }
289
288
290
289
/** Returns a value class containing operations for comparing the size of this $coll to a test value.
291
290
*
@@ -304,19 +303,19 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
304
303
@ inline final def sizeIs : IterableOps .SizeCompareOps = new IterableOps .SizeCompareOps (this )
305
304
306
305
/** Compares the size of this $coll to the size of another `Iterable`.
307
- *
308
- * @param that the `Iterable` whose size is compared with this $coll's size.
309
- * @return A value `x` where
310
- * {{{
311
- * x < 0 if this.size < that.size
312
- * x == 0 if this.size == that.size
313
- * x > 0 if this.size > that.size
314
- * }}}
315
- *
316
- * The method as implemented here does not call `size` directly; its running time
317
- * is `O(this.size min that.size)` instead of `O(this.size + that.size)`.
318
- * The method should be overridden if computing `size` is cheap and `knownSize` returns `-1`.
319
- */
306
+ *
307
+ * @param that the `Iterable` whose size is compared with this $coll's size.
308
+ * @return A value `x` where
309
+ * {{{
310
+ * x < 0 if this.size < that.size
311
+ * x == 0 if this.size == that.size
312
+ * x > 0 if this.size > that.size
313
+ * }}}
314
+ *
315
+ * The method as implemented here does not call `size` directly; its running time
316
+ * is `O(this.size min that.size)` instead of `O(this.size + that.size)`.
317
+ * The method should be overridden if computing `size` is cheap and `knownSize` returns `-1`.
318
+ */
320
319
def sizeCompare (that : Iterable [_]): Int = {
321
320
val thatKnownSize = that.knownSize
322
321
@@ -345,39 +344,39 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
345
344
def view (from : Int , until : Int ): View [A ] = view.slice(from, until)
346
345
347
346
/** Transposes this $coll of iterable collections into
348
- * a $coll of ${coll}s.
349
- *
350
- * The resulting collection's type will be guided by the
351
- * static type of $coll. For example:
352
- *
353
- * {{{
354
- * val xs = List(
355
- * Set(1, 2, 3),
356
- * Set(4, 5, 6)).transpose
357
- * // xs == List(
358
- * // List(1, 4),
359
- * // List(2, 5),
360
- * // List(3, 6))
361
- *
362
- * val ys = Vector(
363
- * List(1, 2, 3),
364
- * List(4, 5, 6)).transpose
365
- * // ys == Vector(
366
- * // Vector(1, 4),
367
- * // Vector(2, 5),
368
- * // Vector(3, 6))
369
- * }}}
370
- *
371
- * $willForceEvaluation
372
- *
373
- * @tparam B the type of the elements of each iterable collection.
374
- * @param asIterable an implicit conversion which asserts that the
375
- * element type of this $coll is an `Iterable`.
376
- * @return a two-dimensional $coll of ${coll}s which has as ''n''th row
377
- * the ''n''th column of this $coll.
378
- * @throws IllegalArgumentException if all collections in this $coll
379
- * are not of the same size.
380
- */
347
+ * a $coll of ${coll}s.
348
+ *
349
+ * The resulting collection's type will be guided by the
350
+ * static type of $coll. For example:
351
+ *
352
+ * {{{
353
+ * val xs = List(
354
+ * Set(1, 2, 3),
355
+ * Set(4, 5, 6)).transpose
356
+ * // xs == List(
357
+ * // List(1, 4),
358
+ * // List(2, 5),
359
+ * // List(3, 6))
360
+ *
361
+ * val ys = Vector(
362
+ * List(1, 2, 3),
363
+ * List(4, 5, 6)).transpose
364
+ * // ys == Vector(
365
+ * // Vector(1, 4),
366
+ * // Vector(2, 5),
367
+ * // Vector(3, 6))
368
+ * }}}
369
+ *
370
+ * $willForceEvaluation
371
+ *
372
+ * @tparam B the type of the elements of each iterable collection.
373
+ * @param asIterable an implicit conversion which asserts that the
374
+ * element type of this $coll is an `Iterable`.
375
+ * @return a two-dimensional $coll of ${coll}s which has as ''n''th row
376
+ * the ''n''th column of this $coll.
377
+ * @throws IllegalArgumentException if all collections in this $coll
378
+ * are not of the same size.
379
+ */
381
380
def transpose [B ](implicit asIterable : A => /* <:<!!!*/ Iterable [B ]): CC [CC [B ] @ uncheckedVariance] = {
382
381
if (isEmpty)
383
382
return iterableFactory.empty[CC [B ]]
@@ -717,32 +716,32 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
717
716
(iterableFactory.from(left), iterableFactory.from(right))
718
717
}
719
718
720
- /** Returns a new $coll containing the elements from the left hand operand followed by the elements from the
721
- * right hand operand. The element type of the $coll is the most specific superclass encompassing
722
- * the element types of the two operands.
723
- *
724
- * @param suffix the iterable to append.
725
- * @tparam B the element type of the returned collection.
726
- * @return a new $coll which contains all elements
727
- * of this $coll followed by all elements of `suffix`.
728
- */
719
+ /** Returns a new $ccoll containing the elements from the left hand operand followed by the elements from the
720
+ * right hand operand. The element type of the $ccoll is the most specific superclass encompassing
721
+ * the element types of the two operands.
722
+ *
723
+ * @param suffix the iterable to append.
724
+ * @tparam B the element type of the returned collection.
725
+ * @return a new $coll which contains all elements
726
+ * of this $coll followed by all elements of `suffix`.
727
+ */
729
728
def concat [B >: A ](suffix : IterableOnce [B ]): CC [B ] = iterableFactory.from(suffix match {
730
729
case xs : Iterable [B ] => new View .Concat (this , xs)
731
730
case xs => iterator ++ suffix.iterator
732
731
})
733
732
734
733
/** Alias for `concat` */
735
- @ ` inline` final def ++ [B >: A ](suffix : IterableOnce [B ]): CC [B ] = concat(suffix)
734
+ @ inline final def ++ [B >: A ](suffix : IterableOnce [B ]): CC [B ] = concat(suffix)
736
735
737
- /** Returns a $coll formed from this $coll and another iterable collection
738
- * by combining corresponding elements in pairs.
739
- * If one of the two collections is longer than the other, its remaining elements are ignored.
740
- *
741
- * @param that The iterable providing the second half of each result pair
742
- * @tparam B the type of the second half of the returned pairs
743
- * @return a new $coll containing pairs consisting of corresponding elements of this $coll and `that`.
744
- * The length of the returned collection is the minimum of the lengths of this $coll and `that`.
745
- */
736
+ /** Returns a $ccoll formed from this $coll and another iterable collection
737
+ * by combining corresponding elements in pairs.
738
+ * If one of the two collections is longer than the other, its remaining elements are ignored.
739
+ *
740
+ * @param that The iterable providing the second half of each result pair
741
+ * @tparam B the type of the second half of the returned pairs
742
+ * @return a new $ccoll containing pairs consisting of corresponding elements of this $coll and `that`.
743
+ * The length of the returned collection is the minimum of the lengths of this $coll and `that`.
744
+ */
746
745
def zip [B ](that : IterableOnce [B ]): CC [(A @ uncheckedVariance, B )] = iterableFactory.from(that match { // sound bcs of VarianceNote
747
746
case that : Iterable [B ] => new View .Zip (this , that)
748
747
case _ => iterator.zip(that)
@@ -862,7 +861,7 @@ object IterableOps {
862
861
/** Operations for comparing the size of a collection to a test value.
863
862
*
864
863
* These operations are implemented in terms of
865
- * [[scala.collection.IterableOps.sizeCompare(Int) `sizeCompare(Int)` ]].
864
+ * [[scala.collection.IterableOps! .sizeCompare(Int):Int* `sizeCompare(Int)` ]]
866
865
*/
867
866
final class SizeCompareOps private [collection](val it : IterableOps [_, AnyConstr , _]) extends AnyVal {
868
867
/** Tests if the size of the collection is less than some value. */
0 commit comments