Instance Methodswift 6.0.1Swift
index(_:offsetBy:)
func index(_ i: Int, offsetBy n: Int) -> Int
Other members in extension
Typealiases
Type members
init(mutating: UnsafeBufferPointer<Element>
) Creates a mutable typed buffer pointer referencing the same memory as the given immutable buffer pointer.
init(rebasing: Slice<UnsafeMutableBufferPointer<Element>>
) Creates a buffer over the same memory as the given buffer slice.
init(start: UnsafeMutablePointer<Element>?, count: Int
) Creates a new buffer pointer over the specified number of contiguous instances beginning at the given pointer.
static func allocate(capacity: Int
) -> UnsafeMutableBufferPointer<Element> Allocates uninitialized memory for the specified number of instances of type
Element
.
Instance members
var baseAddress: UnsafeMutablePointer<Element>?
A pointer to the first element of the buffer.
let count: Int
The number of elements in the buffer.
var debugDescription: String
A textual representation of the buffer, suitable for debugging.
var endIndex: Int
The “past the end” position—that is, the position one greater than the last valid subscript argument.
var indices: UnsafeMutableBufferPointer<Element>.Indices
var isEmpty: Bool
A Boolean value indicating whether the buffer is empty.
var startIndex: Int
The index of the first element in a nonempty buffer.
subscript(Int
) -> Element Accesses the element at the specified position.
subscript(Range<Int>
) -> Slice<UnsafeMutableBufferPointer<Element>> Accesses a contiguous subrange of the buffer’s elements.
subscript(Int
) -> Element Accesses the element at the specified position.
func deallocate(
) Deallocates the memory block previously allocated at this buffer pointer’s base address.
func deinitialize(
) -> UnsafeMutableRawBufferPointer Deinitializes every instance in this buffer.
func deinitializeElement(at: UnsafeMutableBufferPointer<Element>.Index
) Deinitializes the memory underlying the element at
index
.func distance(from: Int, to: Int
) -> Int func extracting(Range<Int>
) -> UnsafeMutableBufferPointer<Element> Constructs a standalone buffer pointer over the items within the supplied range of positions in the memory region addressed by this buffer pointer.
func extracting(some RangeExpression<Int>
) -> UnsafeMutableBufferPointer<Element> Constructs a standalone buffer pointer over the items within the supplied range of positions in the memory region addressed by this buffer pointer.
func extracting((UnboundedRange_) -> ()
) -> UnsafeMutableBufferPointer<Element> Extracts and returns a copy of the entire buffer.
func formIndex(after: inout Int
) func formIndex(before: inout Int
) func index(Int, offsetBy: Int, limitedBy: Int
) -> Int? func index(after: Int
) -> Int func index(before: Int
) -> Int func initialize<S>(from: S
) -> (unwritten: S.Iterator, index: UnsafeMutableBufferPointer<Element>.Index) Initializes the buffer’s memory with the given elements.
func initialize(fromContentsOf: some Collection<Element>
) -> UnsafeMutableBufferPointer<Element>.Index Initializes the buffer’s memory with every element of the source.
func initialize(repeating: Element
) Initializes every element in this buffer’s memory to a copy of the given value.
func initializeElement(at: UnsafeMutableBufferPointer<Element>.Index, to: consuming Element
) Initializes the element at
index
to the given value.func makeIterator(
) -> UnsafeMutableBufferPointer<Element>.Iterator Returns an iterator over the elements of this buffer.
func moveElement(from: UnsafeMutableBufferPointer<Element>.Index
) -> Element Retrieves and returns the element at
index
, leaving that element’s underlying memory uninitialized.func moveInitialize(fromContentsOf: Slice<UnsafeMutableBufferPointer<Element>>
) -> UnsafeMutableBufferPointer<Element>.Index Moves every element of an initialized source buffer into the uninitialized memory referenced by this buffer, leaving the source memory uninitialized and this buffer’s memory initialized.
func moveInitialize(fromContentsOf: UnsafeMutableBufferPointer<Element>
) -> UnsafeMutableBufferPointer<Element>.Index Moves every element of an initialized source buffer into the uninitialized memory referenced by this buffer, leaving the source memory uninitialized and this buffer’s memory initialized.
func moveUpdate(fromContentsOf: Slice<UnsafeMutableBufferPointer<Element>>
) -> UnsafeMutableBufferPointer<Element>.Index Updates this buffer’s initialized memory initialized memory by moving every element from the source buffer slice, leaving the source memory uninitialized.
func moveUpdate(fromContentsOf: UnsafeMutableBufferPointer<Element>
) -> UnsafeMutableBufferPointer<Element>.Index Updates this buffer’s initialized memory initialized memory by moving every element from the source buffer, leaving the source memory uninitialized.
func swapAt(Int, Int
) Exchanges the values at the specified indices of the buffer.
func update<S>(from: S
) -> (unwritten: S.Iterator, index: UnsafeMutableBufferPointer<Element>.Index) Updates the buffer’s initialized memory with the given elements.
func update(fromContentsOf: some Collection<Element>
) -> UnsafeMutableBufferPointer<Element>.Index Updates the buffer’s initialized memory with every element of the source.
func update(repeating: Element
) Updates every element of this buffer’s initialized memory.
func withContiguousMutableStorageIfAvailable<R>((inout UnsafeMutableBufferPointer<Element>) throws -> R
) rethrows -> R? func withContiguousStorageIfAvailable<R>((UnsafeBufferPointer<Element>) throws -> R
) rethrows -> R? func withMemoryRebound<T, E, Result>(to: T.Type, (UnsafeMutableBufferPointer<T>)
throws Executes the given closure while temporarily binding the memory referenced by this buffer to the given type.