Instance Method

distance(from:to:)

Returns the distance between two indices.

Declaration

func distance(from start: Int, to end: Int) -> Int

Parameters

start

A valid index of the collection.

end

Another valid index of the collection. If end is equal to start, the result is zero.

Return Value

The distance between start and end.

Discussion

Complexity: O(1)

See Also

Manipulating Index Ranges

typealias Data.Indices

A type used to indicate a range of positions in a data's buffer.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software