Skip to content

Commit a2893eb

Browse files
authored
Merge pull request scala/scala#10218 from som-snytt/issue/12681-range-doc
Find more doc vars and distinguish C from CC [ci: last-only]
2 parents 78d1d31 + dfdd7fd commit a2893eb

14 files changed

+286
-289
lines changed

library/src/scala/collection/Factory.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ trait IterableFactory[+CC[_]] extends Serializable {
9090
*/
9191
def from[A](source: IterableOnce[A]): CC[A]
9292

93-
/** An empty collection
93+
/** An empty $coll
9494
* @tparam A the type of the ${coll}'s elements
9595
*/
9696
def empty[A]: CC[A]

library/src/scala/collection/Iterable.scala

Lines changed: 100 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ trait Iterable[+A] extends IterableOnce[A]
127127
* @define willNotTerminateInf
128128
*
129129
* Note: will not terminate for infinite-sized collections.
130-
* @define undefinedorder
130+
* @define undefinedorder
131131
* The order in which operations are performed on elements is unspecified
132132
* and may be nondeterministic.
133133
*/
@@ -140,9 +140,9 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
140140
def toIterable: Iterable[A]
141141

142142
/** 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+
*/
146146
@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")
147147
final def toTraversable: Traversable[A] = toIterable
148148

@@ -208,24 +208,24 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
208208
*/
209209
protected def newSpecificBuilder: Builder[A @uncheckedVariance, C]
210210

211-
/** The empty iterable of the same type as this iterable.
211+
/** The empty $coll.
212212
*
213-
* @return an empty iterable of type `C`.
213+
* @return an empty iterable of type $Coll.
214214
*/
215215
def empty: C = fromSpecific(Nil)
216216

217217
/** 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+
*/
222222
def head: A = iterator.next()
223223

224224
/** 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+
*/
229229
def headOption: Option[A] = {
230230
val it = iterator
231231
if (it.hasNext) Some(it.next()) else None
@@ -244,32 +244,32 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
244244
}
245245

246246
/** 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+
*/
251251
def lastOption: Option[A] = if (isEmpty) None else Some(last)
252252

253253
/** A view over the elements of this collection. */
254254
def view: View[A] = View.fromIteratorProvider(() => iterator)
255255

256256
/** 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 =
273273
if (otherSize < 0) 1
274274
else {
275275
val known = knownSize
@@ -285,7 +285,6 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
285285
i - otherSize
286286
}
287287
}
288-
}
289288

290289
/** Returns a value class containing operations for comparing the size of this $coll to a test value.
291290
*
@@ -304,19 +303,19 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
304303
@inline final def sizeIs: IterableOps.SizeCompareOps = new IterableOps.SizeCompareOps(this)
305304

306305
/** 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+
*/
320319
def sizeCompare(that: Iterable[_]): Int = {
321320
val thatKnownSize = that.knownSize
322321

@@ -345,39 +344,39 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
345344
def view(from: Int, until: Int): View[A] = view.slice(from, until)
346345

347346
/** 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+
*/
381380
def transpose[B](implicit asIterable: A => /*<:<!!!*/ Iterable[B]): CC[CC[B] @uncheckedVariance] = {
382381
if (isEmpty)
383382
return iterableFactory.empty[CC[B]]
@@ -717,32 +716,32 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
717716
(iterableFactory.from(left), iterableFactory.from(right))
718717
}
719718

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+
*/
729728
def concat[B >: A](suffix: IterableOnce[B]): CC[B] = iterableFactory.from(suffix match {
730729
case xs: Iterable[B] => new View.Concat(this, xs)
731730
case xs => iterator ++ suffix.iterator
732731
})
733732

734733
/** 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)
736735

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+
*/
746745
def zip[B](that: IterableOnce[B]): CC[(A @uncheckedVariance, B)] = iterableFactory.from(that match { // sound bcs of VarianceNote
747746
case that: Iterable[B] => new View.Zip(this, that)
748747
case _ => iterator.zip(that)
@@ -862,7 +861,7 @@ object IterableOps {
862861
/** Operations for comparing the size of a collection to a test value.
863862
*
864863
* These operations are implemented in terms of
865-
* [[scala.collection.IterableOps.sizeCompare(Int) `sizeCompare(Int)`]].
864+
* [[scala.collection.IterableOps!.sizeCompare(Int):Int* `sizeCompare(Int)`]]
866865
*/
867866
final class SizeCompareOps private[collection](val it: IterableOps[_, AnyConstr, _]) extends AnyVal {
868867
/** Tests if the size of the collection is less than some value. */

0 commit comments

Comments
 (0)