Returns the distance between two indices.
SDK
- Xcode 7.1+
Framework
- Swift Standard Library
Declaration
Parameters
start
A valid index of the collection.
end
Another valid index of the collection. If
end
is equal tostart
, the result is zero.
Return Value
The distance between start
and end
. The result can be negative only if the collection conforms to the Bidirectional
protocol.
Discussion
Unless the collection conforms to the Bidirectional
protocol, start
must be less than or equal to end
.
Complexity: O(1) if the collection conforms to Random
; otherwise, O(k), where k is the resulting distance.
Note
This documentation comment was inherited from Bidirectional
.