Skip to content

Commit 04a035c

Browse files
committed
Improve sizeCompare doc
1 parent 6c411a6 commit 04a035c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

library/src/scala/collection/Iterable.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,12 @@ transparent trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] w
264264
* x > 0 if this.size > otherSize
265265
* ```
266266
*
267-
* The method as implemented here does not call `size` directly; its running time
268-
* is `O(size min otherSize)` instead of `O(size)`. The method should be overridden
269-
* if computing `size` is cheap and `knownSize` returns `-1`.
267+
* The default implementation does not call `size`, which may be arbitrarily expensive.
268+
* It will use `knownSize` if nonnegative.
269+
* Otherwise, it will iterate to compute an element count,
270+
* with complexity `O(size min otherSize)`.
271+
* This method should be overridden if computing `size` is cheap and `knownSize` returns `-1`.
272+
* In that case, the custom implementation should just compare `size` and `otherSize` directly.
270273
*
271274
* @see [[sizeIs]]
272275
*/

0 commit comments

Comments
 (0)