index(before:)
Returns the position immediately before the given index.
func index(before i: Self.Index) -> Self.Index
Parameters
- i
A valid index of the collection.
i
must be greater thanstartIndex
.
Returns
The index value immediately before i
.
Returns the position immediately before the given index.
func index(before i: Self.Index) -> Self.Index
A valid index of the collection. i
must be greater than startIndex
.
The index value immediately before i
.
import Swift
protocol BidirectionalCollection<Element> : Collection where Self.Indices : BidirectionalCollection, Self.SubSequence : BidirectionalCollection
A collection that supports backward as well as forward traversal.
associatedtype Index : Comparable where Self.Index == Self.Indices.Element, Self.Indices.Element == Self.Indices.Index, Self.Indices.Index == Self.SubSequence.Index
A type that represents a position in the collection.
associatedtype Element
associatedtype Index
associatedtype Indices
associatedtype SubSequence
override var endIndex: Self.Index { get }
override var indices: Self.Indices { get }
The indices that are valid for subscripting the collection, in ascending order.
override var startIndex: Self.Index { get }
override subscript(bounds: Range<Self.Index>) -> Self.SubSequence { get }
Accesses a contiguous subrange of the collection’s elements.
override subscript(position: Self.Index) -> Self.Element { get }
func distance(from start: Self.Index, to end: Self.Index) -> Int
Returns the distance between two indices.
override func formIndex(after i: inout Self.Index)
Replaces the given index with its successor.
func formIndex(before i: inout Self.Index)
Replaces the given index with its predecessor.
func index(_ i: Self.Index, offsetBy distance: Int) -> Self.Index
Returns an index that is the specified distance from the given index.
func index(_ i: Self.Index, offsetBy distance: Int, limitedBy limit: Self.Index) -> Self.Index?
Returns an index that is the specified distance from the given index, unless that distance is beyond a given limiting index.
override func index(after i: Self.Index) -> Self.Index
Returns the position immediately after the given index.
override func index(before i: Self.Index) -> Self.Index
Returns the position immediately before the given index.
func index(before i: Self.Index) -> Self.Index
Returns the position immediately after the given index.
import SwiftSyntax
A library for working with Swift code.
func index(before index: SyntaxChildrenIndex) -> SyntaxChildrenIndex