-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Description
/// - Complexity: O(1), except if the sequence also conforms to `Collection`.
/// In this case, see the documentation of `Collection.underestimatedCount`.
This was done in ea49459
The correct complexity bound is O(N) where N is the length of the sequence.
The current wording is meaningless, other than to say the complexity bound is O(N) (as given by Collection's requirements). When you are handling a Sequence
, (modulo dynamic casts that you couldn't even perform when that change was made and that nobody does in practice), you don't know that it isn't a Collection
. Furthermore, nearly any Sequence
can be made to conform to Collection
post-hoc. I don't know what made anyone think they could tighten a complexity bound on an existing protocol, but (obviously) when you do that you break anyone that had a previously-valid conformance. More generally, it is broken and wrong to loosen constraints in a refinement. In this case that would make every Collection
not-a Sequence
.
Reproduction
Read the docs.
Expected behavior
The docs make sense and are meaningful.
Environment
Any environment you like
Additional information
No response