Skip to content

Commit a859e38

Browse files
committed
Find more doc vars and distinguish C from CC
1 parent 62d069e commit a859e38

File tree

9 files changed

+72
-74
lines changed

9 files changed

+72
-74
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,8 @@ trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with Iterable
717717
(iterableFactory.from(left), iterableFactory.from(right))
718718
}
719719

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
720+
/** Returns a new $ccoll containing the elements from the left hand operand followed by the elements from the
721+
* right hand operand. The element type of the $ccoll is the most specific superclass encompassing
722722
* the element types of the two operands.
723723
*
724724
* @param suffix the iterable to append.
@@ -862,7 +862,7 @@ object IterableOps {
862862
/** Operations for comparing the size of a collection to a test value.
863863
*
864864
* These operations are implemented in terms of
865-
* [[scala.collection.IterableOps.sizeCompare(Int) `sizeCompare(Int)`]].
865+
* [[scala.collection.IterableOps!.sizeCompare(Int):Int* `sizeCompare(Int)`]]
866866
*/
867867
final class SizeCompareOps private[collection](val it: IterableOps[_, AnyConstr, _]) extends AnyVal {
868868
/** Tests if the size of the collection is less than some value. */

library/src/scala/collection/IterableOnce.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import scala.runtime.{AbstractFunction1, AbstractFunction2}
4040
* without inheriting unwanted implementations.
4141
*
4242
* @define coll collection
43+
* @define ccoll $coll
4344
*/
4445
trait IterableOnce[+A] extends Any {
4546

@@ -318,8 +319,6 @@ object IterableOnce {
318319
* The order of applications of the operator is unspecified and may be nondeterministic.
319320
* @define exactlyOnce
320321
* Each element appears exactly once in the computation.
321-
* @define coll collection
322-
*
323322
*/
324323
trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
325324
/////////////////////////////////////////////////////////////// Abstract methods that must be implemented
@@ -439,16 +438,16 @@ trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
439438
*/
440439
def slice(from: Int, until: Int): C
441440

442-
/** Builds a new $coll by applying a function to all elements of this $coll.
441+
/** Builds a new $ccoll by applying a function to all elements of this $coll.
443442
*
444443
* @param f the function to apply to each element.
445-
* @tparam B the element type of the returned $coll.
446-
* @return a new $coll resulting from applying the given function
444+
* @tparam B the element type of the returned $ccoll.
445+
* @return a new $ccoll resulting from applying the given function
447446
* `f` to each element of this $coll and collecting the results.
448447
*/
449448
def map[B](f: A => B): CC[B]
450449

451-
/** Builds a new $coll by applying a function to all elements of this $coll
450+
/** Builds a new $ccoll by applying a function to all elements of this $coll
452451
* and using the elements of the resulting collections.
453452
*
454453
* For example:

library/src/scala/collection/Iterator.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,17 +844,14 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
844844
* @param that the collection to compare
845845
* @tparam B the type of the elements of collection `that`.
846846
* @return `true` if both collections contain equal elements in the same order, `false` otherwise.
847-
*
848-
* @inheritdoc
849847
*/
850848
def sameElements[B >: A](that: IterableOnce[B]): Boolean = {
851849
val those = that.iterator
852-
while (hasNext && those.hasNext)
853-
if (next() != those.next())
854-
return false
855-
// At that point we know that *at least one* iterator has no next element
856-
// If *both* of them have no elements then the collections are the same
857-
hasNext == those.hasNext
850+
while (hasNext) {
851+
if (!those.hasNext) return false
852+
if (next() != those.next()) return false
853+
}
854+
!those.hasNext
858855
}
859856

860857
/** Creates two new iterators that both iterate over the same elements

library/src/scala/collection/Seq.scala

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -843,16 +843,23 @@ trait SeqOps[+A, +CC[_], +C] extends Any
843843

844844
override def isEmpty: Boolean = lengthCompare(0) == 0
845845

846-
/** Tests whether the elements of this collection are the same (and in the same order)
847-
* as those of `that`.
848-
*/
846+
/** Checks whether corresponding elements of the given iterable collection
847+
* compare equal (with respect to `==`) to elements of this $coll.
848+
*
849+
* @param that the collection to compare
850+
* @tparam B the type of the elements of collection `that`.
851+
* @return `true` if both collections contain equal elements in the same order, `false` otherwise.
852+
*/
849853
def sameElements[B >: A](that: IterableOnce[B]): Boolean = {
850854
val thisKnownSize = knownSize
851-
val knownSizeDifference = thisKnownSize != -1 && {
855+
if (thisKnownSize != -1) {
852856
val thatKnownSize = that.knownSize
853-
thatKnownSize != -1 && thisKnownSize != thatKnownSize
857+
if (thatKnownSize != -1) {
858+
if (thisKnownSize != thatKnownSize) return false
859+
if (thisKnownSize == 0) return true
860+
}
854861
}
855-
!knownSizeDifference && iterator.sameElements(that)
862+
iterator.sameElements(that)
856863
}
857864

858865
/** Tests whether every element of this $coll relates to the

library/src/scala/collection/Set.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]]
210210
@deprecated("Use &- with an explicit collection argument instead of - with varargs", "2.13.0")
211211
def - (elem1: A, elem2: A, elems: A*): C = diff(elems.toSet + elem1 + elem2)
212212

213-
/** Creates a new $coll by adding all elements contained in another collection to this $coll, omitting duplicates.
214-
*
215-
* This method takes a collection of elements and adds all elements, omitting duplicates, into $coll.
213+
/** Creates a new $ccoll by adding all elements contained in another collection to this $coll, omitting duplicates.
216214
*
217215
* Example:
218216
* {{{

library/src/scala/collection/SortedSet.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]]
5757
*/
5858
def sortedIterableFactory: SortedIterableFactory[CC]
5959

60+
/** Widens the type of this set to its unsorted counterpart. */
6061
def unsorted: Set[A]
6162

6263
/**

library/src/scala/collection/immutable/Range.scala

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,43 @@ import scala.collection.{AbstractIterator, AnyStepper, IterableFactoryDefaults,
2020
import scala.util.hashing.MurmurHash3
2121

2222
/** The `Range` class represents integer values in range
23-
* ''[start;end)'' with non-zero step value `step`.
24-
* It's a special case of an indexed sequence.
25-
* For example:
26-
*
27-
* {{{
28-
* val r1 = 0 until 10
29-
* val r2 = r1.start until r1.end by r1.step + 1
30-
* println(r2.length) // = 5
31-
* }}}
32-
*
33-
* Ranges that contain more than `Int.MaxValue` elements can be created, but
34-
* these overfull ranges have only limited capabilities. Any method that
35-
* could require a collection of over `Int.MaxValue` length to be created, or
36-
* could be asked to index beyond `Int.MaxValue` elements will throw an
37-
* exception. Overfull ranges can safely be reduced in size by changing
38-
* the step size (e.g. `by 3`) or taking/dropping elements. `contains`,
39-
* `equals`, and access to the ends of the range (`head`, `last`, `tail`,
40-
* `init`) are also permitted on overfull ranges.
41-
*
42-
* @param start the start of this range.
43-
* @param end the end of the range. For exclusive ranges, e.g.
44-
* `Range(0,3)` or `(0 until 3)`, this is one
45-
* step past the last one in the range. For inclusive
46-
* ranges, e.g. `Range.inclusive(0,3)` or `(0 to 3)`,
47-
* it may be in the range if it is not skipped by the step size.
48-
* To find the last element inside a non-empty range,
49-
* use `last` instead.
50-
* @param step the step for the range.
51-
*
52-
* @define coll range
53-
* @define mayNotTerminateInf
54-
* @define willNotTerminateInf
55-
* @define doesNotUseBuilders
56-
* '''Note:''' this method does not use builders to construct a new range,
57-
* and its complexity is O(1).
58-
*/
23+
* ''[start;end)'' with non-zero step value `step`.
24+
* It's a special case of an indexed sequence.
25+
* For example:
26+
*
27+
* {{{
28+
* val r1 = 0 until 10
29+
* val r2 = r1.start until r1.end by r1.step + 1
30+
* println(r2.length) // = 5
31+
* }}}
32+
*
33+
* Ranges that contain more than `Int.MaxValue` elements can be created, but
34+
* these overfull ranges have only limited capabilities. Any method that
35+
* could require a collection of over `Int.MaxValue` length to be created, or
36+
* could be asked to index beyond `Int.MaxValue` elements will throw an
37+
* exception. Overfull ranges can safely be reduced in size by changing
38+
* the step size (e.g. `by 3`) or taking/dropping elements. `contains`,
39+
* `equals`, and access to the ends of the range (`head`, `last`, `tail`,
40+
* `init`) are also permitted on overfull ranges.
41+
*
42+
* @param start the start of this range.
43+
* @param end the end of the range. For exclusive ranges, e.g.
44+
* `Range(0,3)` or `(0 until 3)`, this is one
45+
* step past the last one in the range. For inclusive
46+
* ranges, e.g. `Range.inclusive(0,3)` or `(0 to 3)`,
47+
* it may be in the range if it is not skipped by the step size.
48+
* To find the last element inside a non-empty range,
49+
* use `last` instead.
50+
* @param step the step for the range.
51+
*
52+
* @define coll range
53+
* @define ccoll indexed sequence
54+
* @define mayNotTerminateInf
55+
* @define willNotTerminateInf
56+
* @define doesNotUseBuilders
57+
* '''Note:''' this method does not use builders to construct a new range,
58+
* and its complexity is O(1).
59+
*/
5960
@SerialVersionUID(3L)
6061
sealed abstract class Range(
6162
val start: Int,
@@ -522,11 +523,7 @@ sealed abstract class Range(
522523
}
523524
}
524525

525-
/**
526-
* Companion object for ranges.
527-
* @define Coll `Range`
528-
* @define coll range
529-
*/
526+
/** Companion object for ranges. */
530527
object Range {
531528

532529
/** Counts the number of range elements.

library/src/scala/collection/mutable/SortedSet.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ package scala
1414
package collection
1515
package mutable
1616

17-
/**
18-
* Base type for mutable sorted set collections
19-
*/
17+
/** Base type for mutable sorted set collections
18+
*/
2019
trait SortedSet[A]
2120
extends Set[A]
2221
with collection.SortedSet[A]
@@ -30,7 +29,7 @@ trait SortedSet[A]
3029

3130
/**
3231
* @define coll mutable sorted set
33-
* @define Coll `mutable.Sortedset`
32+
* @define Coll `mutable.SortedSet`
3433
*/
3534
trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]]
3635
extends SetOps[A, Set, C]
@@ -41,8 +40,8 @@ trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]]
4140

4241
/**
4342
* $factoryInfo
44-
* @define coll mutable sorted set
45-
* @define Coll `mutable.Sortedset`
43+
* @define xcoll mutable sorted set
44+
* @define xColl `mutable.SortedSet`
4645
*/
4746
@SerialVersionUID(3L)
4847
object SortedSet extends SortedIterableFactory.Delegate[SortedSet](TreeSet)

0 commit comments

Comments
 (0)