protocol ReverseIndexType
Inheritance 
BidirectionalIndexType, Equatable, ForwardIndexType, _Incrementable
View Protocol Hierarchy →


Associated Types 
Base : BidirectionalIndexType
Distance : _SignedIntegerType = Self.Base.Distance

Import  import Swift 
Initializers
Instance Variables
The successor position in the underlying (unreversed) collection.
If self
is advance(c.reverse.startIndex, n)
, then:
 self.base
is advance(c.endIndex, n)
.
 if n
!= c.count
, then c.reverse[self]
is
equivalent to [self.base.predecessor()]
.
Declaration
var base: Self.Base { get }
Instance Methods
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 tripleequals ===
is notably not part of an instance's value. Exposing other
nonvalue 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
Return the result of advancing self
by n
positions.
Returns:
 If n > 0
, the result of applying successor
to self
n
times.
 If n < 0
, the result of applying predecessor
to self
n
times.
 Otherwise, self
.
Requires: n >= 0
if only conforming to ForwardIndexType
Complexity:
 O(1) if conforming to RandomAccessIndexType
 O(abs(n)
) otherwise
Declaration
func advancedBy(n: Self.Distance) > Self
Declared In
ForwardIndexType
Return the result of advancing self
by n
positions, or until it
equals limit
.
Returns:
 If n > 0
, the result of applying successor
to self
n
times
but not past limit
.
 If n < 0
, the result of applying predecessor
to self
n
times
but not past limit
.
 Otherwise, self
.
Requires: n >= 0
if only conforming to ForwardIndexType
.
Complexity:
 O(1) if conforming to RandomAccessIndexType
 O(abs(n)
) otherwise
Declaration
func advancedBy(n: Self.Distance, limit: Self) > Self
Declared In
ForwardIndexType
Measure the distance between self
and end
.
Requires:
 start
and end
are part of the same sequence when conforming to
RandomAccessSequenceType
.
 end
is reachable from self
by incrementation otherwise.
Complexity:
 O(1) if conforming to RandomAccessIndexType
 O(n
) otherwise, where n
is the function's result.
Declaration
func distanceTo(end: Self) > Self.Distance
Declared In
ForwardIndexType
Return the previous consecutive value in a discrete sequence.
If self
has a welldefined successor,
self.successor().predecessor() == self
. If self
has a
welldefined predecessor, self.predecessor().successor() ==
self
.
Requires: self
has a welldefined predecessor.
Declaration
func predecessor() > Self
Declared In
BidirectionalIndexType
Return the next consecutive value in a discrete sequence of
Self
values.
Requires: self
has a welldefined successor.
Declaration
func successor() > Self
Declared In
_Incrementable
Default Implementations
Return the result of advancing self
by n
positions.
Returns:
 If n > 0
, the result of applying successor
to self
n
times.
 If n < 0
, the result of applying predecessor
to self
n
times.
 Otherwise, self
.
Requires: n >= 0
if only conforming to ForwardIndexType
Complexity:
 O(1) if conforming to RandomAccessIndexType
 O(abs(n)
) otherwise
Declaration
func advancedBy(n: Self.Distance) > Self
Declared In
BidirectionalIndexType
, ForwardIndexType
Return the result of advancing self
by n
positions, or until it
equals limit
.
Returns:
 If n > 0
, the result of applying successor
to self
n
times
but not past limit
.
 If n < 0
, the result of applying predecessor
to self
n
times
but not past limit
.
 Otherwise, self
.
Requires: n >= 0
if only conforming to ForwardIndexType
.
Complexity:
 O(1) if conforming to RandomAccessIndexType
 O(abs(n)
) otherwise
Declaration
func advancedBy(n: Self.Distance, limit: Self) > Self
Declared In
BidirectionalIndexType
, ForwardIndexType
Measure the distance between self
and end
.
Requires:
 start
and end
are part of the same sequence when conforming to
RandomAccessSequenceType
.
 end
is reachable from self
by incrementation otherwise.
Complexity:
 O(1) if conforming to RandomAccessIndexType
 O(n
) otherwise, where n
is the function's result.
Declaration
func distanceTo(end: Self) > Self.Distance
Declared In
BidirectionalIndexType
, ForwardIndexType
A type that can represent the number of steps between pairs of
ReverseIndex
values where one value is reachable from the other.