Instance Methodswift 6.0.1Swift
index(after:)
Returns the position immediately after the given index.
func index(after i: Int) -> Int
Parameters
- i
A valid index of the collection.
i
must be less thanendIndex
.
Returns
The index immediately after i
.
Other members in extension
Typealiases
typealias Index
The index type for arrays,
Int
.typealias Indices
The type that represents the indices that are valid for subscripting an array, in ascending order.
typealias Iterator
The type that allows iteration over an array’s elements.
Type members
init(
) Creates a new, empty array.
init<S>(S
) Creates an array containing the elements of a sequence.
init(arrayLiteral: Element...
) Creates an array from the given array literal.
init(repeating: Element, count: Int
) Creates a new array containing the specified number of a single, repeated value.
Instance members
var capacity: Int
The total number of elements that the array can contain without allocating new storage.
var count: Int
The number of elements in the array.
var customMirror: Mirror
A mirror that reflects the array.
var debugDescription: String
A textual representation of the array and its elements, suitable for debugging.
var description: String
A textual representation of the array and its elements.
var endIndex: Int
The array’s “past the end” position—that is, the position one greater than the last valid subscript argument.
var startIndex: Int
The position of the first element in a nonempty array.
subscript(Range<Int>
) -> ArraySlice<Element> Accesses a contiguous subrange of the array’s elements.
subscript(Int
) -> Element Accesses the element at the specified position.
func append(Element
) Adds a new element at the end of the array.
func append<S>(contentsOf: S
) Adds the elements of a sequence to the end of the array.
func distance(from: Int, to: Int
) -> Int Returns the distance between two indices.
func formIndex(after: inout Int
) func formIndex(before: inout Int
) func index(Int, offsetBy: Int
) -> Int Returns an index that is the specified distance from the given index.
func index(Int, offsetBy: Int, limitedBy: Int
) -> Int? Returns an index that is the specified distance from the given index, unless that distance is beyond a given limiting index.
func index(before: Int
) -> Int Returns the position immediately before the given index.
func insert(Element, at: Int
) Inserts a new element at the specified position.
func remove(at: Int
) -> Element Removes and returns the element at the specified position.
func removeAll(keepingCapacity: Bool
) Removes all elements from the array.
func replaceSubrange<C>(Range<Int>, with: C
) Replaces a range of elements with the elements in the specified collection.
func reserveCapacity(Int
) Reserves enough space to store the specified number of elements.
func withContiguousMutableStorageIfAvailable<R>((inout UnsafeMutableBufferPointer<Element>) throws -> R
) rethrows -> R? func withContiguousStorageIfAvailable<R>((UnsafeBufferPointer<Element>) throws -> R
) rethrows -> R? func withUnsafeBufferPointer<R>((UnsafeBufferPointer<Element>) throws -> R
) rethrows -> R Calls a closure with a pointer to the array’s contiguous storage.
func withUnsafeBytes<R>((UnsafeRawBufferPointer) throws -> R
) rethrows -> R Calls the given closure with a pointer to the underlying bytes of the array’s contiguous storage.
func withUnsafeMutableBufferPointer<R>((inout UnsafeMutableBufferPointer<Element>) throws -> R
) rethrows -> R Calls the given closure with a pointer to the array’s mutable contiguous storage.
func withUnsafeMutableBytes<R>((UnsafeMutableRawBufferPointer) throws -> R
) rethrows -> R Calls the given closure with a pointer to the underlying bytes of the array’s mutable contiguous storage.