protocol
Strideable
Inheritance |
Comparable, Equatable, _Strideable
View Protocol Hierarchy →
|
---|---|
Associated Types |
A type that can represent the distance between two values of |
Import |
|
Instance Methods
A strict total order
over instances of Self
.
Declaration
func
<
(
lhs
:
Self
,
rhs
:
Self
) -
>
Bool
Declared In
Comparable
Return true if lhs
is equal to rhs
.
Equality implies substitutability. When x == y
, x
and
y
are interchangeable in any code that only depends on their
values.
Class instance identity as distinguished by triple-equals ===
is notably not part of an instance's value. Exposing other
non-value aspects of Equatable
types is discouraged, and any
that are exposed should be explicitly pointed out in
documentation.
Equality is an equivalence relation
x == x
istrue
x == y
impliesy == x
x == y
andy == z
impliesx == z
Inequality is the inverse of equality, i.e. !(x == y)
iff
x != y
.
Declaration
func
==(
lhs
:
Self
,
rhs
:
Self
) -
>
Bool
Declared In
Equatable
Returns a Self
x
such that self.distanceTo(x)
approximates
n
.
Complexity: O(1).
See Also: RandomAccessIndexType
's advancedBy
, which
provides a stronger semantic guarantee.
Declaration
func
advancedBy
(
n
:
Self
.
Stride
) -
>
Self
Declared In
Strideable
, _Strideable
Returns a stride x
such that self.advancedBy(x)
approximates
other
.
Complexity: O(1).
See Also: RandomAccessIndexType
's distanceTo
, which provides a
stronger semantic guarantee.
Declaration
func
distanceTo
(
other
:
Self
) -
>
Self
.
Stride
Declared In
Strideable
, _Strideable
5 inherited items hidden. (Show all)
Default Implementations
Return the sequence of values (start
, start + stride
, start +
stride + stride
, ... last) where last is the last value in
the progression less than or equal to end
.
Note: There is no guarantee that end
is an element of the sequence.
Declaration
func
stride
(
through
end
:
Self
,
by
stride
:
Self
.
Stride
) -
>
StrideThrough
<
Self
>
Return the sequence of values (self
, self + stride
, self +
stride + stride
, ... last) where last is the last value in
the progression that is less than end
.
Declaration
func
stride
(
to
end
:
Self
,
by
stride
:
Self
.
Stride
) -
>
StrideTo
<
Self
>
Conforming types are notionally continuous, one-dimensional values that can be offset and measured.