assign(repeating:)
This declaration has been renamed to UnsafeMutableBufferPointer.update(repeating:).
This declaration is deprecated.
func assign(repeating repeatedValue: Element)
This declaration has been renamed to UnsafeMutableBufferPointer.update(repeating:).
This declaration is deprecated.
func assign(repeating repeatedValue: Element)
import Swift
@frozen struct UnsafeMutableBufferPointer<Element> where Element : ~Copyable
A nonowning collection interface to a buffer of mutable elements stored contiguously in memory.
func update(repeating repeatedValue: Element)
Updates every element of this buffer’s initialized memory.
init(mutating other: UnsafeBufferPointer<Element>)
Creates a mutable typed buffer pointer referencing the same memory as the given immutable buffer pointer.
init(rebasing slice: 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 count: Int) -> UnsafeMutableBufferPointer<Element>
Allocates uninitialized memory for the specified number of instances of type Element
.
var baseAddress: UnsafeMutablePointer<Element>? { get }
A pointer to the first element of the buffer.
let count: Int
The number of elements in the buffer.
var debugDescription: String { get }
A textual representation of the buffer, suitable for debugging.
var endIndex: Int { get }
The “past the end” position—that is, the position one greater than the last valid subscript argument.
var indices: UnsafeMutableBufferPointer<Element>.Indices { get }
var isEmpty: Bool { get }
A Boolean value indicating whether the buffer is empty.
var startIndex: Int { get }
The index of the first element in a nonempty buffer.
subscript(i: Int) -> Element { get nonmutating set }
Accesses the element at the specified position.
subscript(bounds: Range<Int>) -> Slice<UnsafeMutableBufferPointer<Element>> { get nonmutating set }
Accesses a contiguous subrange of the buffer’s elements.
subscript(i: Int) -> Element { get nonmutating set }
Accesses the element at the specified position.
func deallocate()
Deallocates the memory block previously allocated at this buffer pointer’s base address.
@discardableResult func deinitialize() -> UnsafeMutableRawBufferPointer
Deinitializes every instance in this buffer.
func deinitializeElement(at index: UnsafeMutableBufferPointer<Element>.Index)
Deinitializes the memory underlying the element at index
.
func distance(from start: Int, to end: Int) -> Int
func extracting(_ bounds: 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(_ bounds: 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(_ bounds: (UnboundedRange_) -> ()) -> UnsafeMutableBufferPointer<Element>
Extracts and returns a copy of the entire buffer.
func formIndex(after i: inout Int)
func formIndex(before i: inout Int)
func index(_ i: Int, offsetBy n: Int) -> Int
func index(_ i: Int, offsetBy n: Int, limitedBy limit: Int) -> Int?
func index(after i: Int) -> Int
func index(before i: Int) -> Int
func initialize<S>(from source: S) -> (unwritten: S.Iterator, index: UnsafeMutableBufferPointer<Element>.Index) where Element == S.Element, S : Sequence
Initializes the buffer’s memory with the given elements.
func initialize(fromContentsOf source: some Collection<Element>) -> UnsafeMutableBufferPointer<Element>.Index
Initializes the buffer’s memory with every element of the source.
func initialize(repeating repeatedValue: Element)
Initializes every element in this buffer’s memory to a copy of the given value.
func initializeElement(at index: UnsafeMutableBufferPointer<Element>.Index, to value: 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 index: UnsafeMutableBufferPointer<Element>.Index) -> Element
Retrieves and returns the element at index
, leaving that element’s underlying memory uninitialized.
func moveInitialize(fromContentsOf source: 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 source: 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 source: 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 source: 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(_ i: Int, _ j: Int)
Exchanges the values at the specified indices of the buffer.
func update<S>(from source: S) -> (unwritten: S.Iterator, index: UnsafeMutableBufferPointer<Element>.Index) where Element == S.Element, S : Sequence
Updates the buffer’s initialized memory with the given elements.
func update(fromContentsOf source: some Collection<Element>) -> UnsafeMutableBufferPointer<Element>.Index
Updates the buffer’s initialized memory with every element of the source.
mutating func withContiguousMutableStorageIfAvailable<R>(_ body: (inout UnsafeMutableBufferPointer<Element>) throws -> R) rethrows -> R?
func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<Element>) throws -> R) rethrows -> R?
func withMemoryRebound<T, E, Result>(to type: T.Type, _ body: (UnsafeMutableBufferPointer<T>) throws(E) -> Result) throws(E) -> Result where E : Error, T : ~Copyable, Result : ~Copyable
Executes the given closure while temporarily binding the memory referenced by this buffer to the given type.
typealias Index = Int
typealias Indices = Range<Int>
typealias Iterator = UnsafeBufferPointer<Element>.Iterator
typealias SubSequence = Slice<UnsafeMutableBufferPointer<Element>>