indices
var indices: UnsafeMutableRawBufferPointer.Indices { get }
var indices: UnsafeMutableRawBufferPointer.Indices { get }
import Swift
@frozen struct UnsafeMutableRawBufferPointer
A mutable nonowning collection interface to the bytes in a region of memory.
typealias Indices = Range<Int>
init(_ bytes: UnsafeMutableRawBufferPointer)
Creates a new buffer over the same memory as the given buffer.
init<T>(_ buffer: UnsafeMutableBufferPointer<T>) where T : ~Copyable
Creates a raw buffer over the contiguous bytes in the given typed buffer.
init(mutating bytes: UnsafeRawBufferPointer)
Creates a new mutable buffer over the same memory as the given buffer.
init(rebasing slice: Slice<UnsafeMutableRawBufferPointer>)
Creates a raw buffer over the same memory as the given raw buffer slice, with the indices rebased to zero.
init(start: UnsafeMutableRawPointer?, count: Int)
Creates a buffer over the specified number of contiguous bytes starting at the given pointer.
static func allocate(byteCount: Int, alignment: Int) -> UnsafeMutableRawBufferPointer
Allocates uninitialized memory with the specified size and alignment.
var baseAddress: UnsafeMutableRawPointer? { get }
A pointer to the first byte of the buffer.
var count: Int { get }
The number of bytes in the buffer.
var debugDescription: String { get }
A textual representation of the buffer, suitable for debugging.
var endIndex: UnsafeMutableRawBufferPointer.Index { get }
The “past the end” position—that is, the position one greater than the last valid subscript argument.
var startIndex: UnsafeMutableRawBufferPointer.Index { get }
Always zero, which is the index of the first byte in a nonempty buffer.
subscript(bounds: Range<Int>) -> UnsafeMutableRawBufferPointer.SubSequence { get nonmutating set }
Accesses the bytes in the specified memory region.
subscript(i: Int) -> UnsafeMutableRawBufferPointer.Element { get nonmutating set }
Accesses the byte at the given offset in the memory region as a UInt8
value.
func assumingMemoryBound<T>(to: T.Type) -> UnsafeMutableBufferPointer<T> where T : ~Copyable
Returns a typed buffer to the memory referenced by this buffer, assuming that the memory is already bound to the specified type.
@discardableResult func bindMemory<T>(to type: T.Type) -> UnsafeMutableBufferPointer<T> where T : ~Copyable
Binds this buffer’s memory to the specified type and returns a typed buffer of the bound memory.
func copyBytes<C>(from source: C) where C : Collection, C.Element == UInt8
Copies from a collection of UInt8
into this buffer’s memory.
func copyMemory(from source: UnsafeRawBufferPointer)
Copies the bytes from the given buffer to this buffer’s memory.
func deallocate()
Deallocates the memory block previously allocated at this buffer pointer’s base address.
func initializeMemory<S>(as type: S.Element.Type, from source: S) -> (unwritten: S.Iterator, initialized: UnsafeMutableBufferPointer<S.Element>) where S : Sequence
Initializes the buffer’s memory with the given elements, binding the initialized memory to the elements’ type.
func initializeMemory<C>(as type: C.Element.Type, fromContentsOf source: C) -> UnsafeMutableBufferPointer<C.Element> where C : Collection
Initializes the buffer’s memory with every element of the source, binding the initialized memory to the elements’ type.
@discardableResult func initializeMemory<T>(as type: T.Type, repeating repeatedValue: T) -> UnsafeMutableBufferPointer<T>
Initializes the memory referenced by this buffer with the given value, binds the memory to the value’s type, and returns a typed buffer of the initialized memory.
func load<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T
Returns a new instance of the given type, read from the buffer pointer’s raw memory at the specified byte offset.
func loadUnaligned<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T
func loadUnaligned<T>(fromByteOffset offset: Int = 0, as type: T.Type) -> T where T : BitwiseCopyable
Returns a new instance of the given type, constructed from the raw memory at the specified offset.
func makeIterator() -> UnsafeMutableRawBufferPointer.Iterator
Returns an iterator over the bytes of this sequence.
@discardableResult func moveInitializeMemory<T>(as type: T.Type, fromContentsOf source: UnsafeMutableBufferPointer<T>) -> UnsafeMutableBufferPointer<T> where T : ~Copyable
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.
@discardableResult func moveInitializeMemory<T>(as type: T.Type, fromContentsOf source: Slice<UnsafeMutableBufferPointer<T>>) -> UnsafeMutableBufferPointer<T>
Moves every element of an initialized source buffer slice into the uninitialized memory referenced by this buffer, leaving the source memory uninitialized and this buffer’s memory initialized.
func storeBytes<T>(of value: T, toByteOffset offset: Int = 0, as type: T.Type)
Stores a value’s bytes into the buffer pointer’s raw memory at the specified byte offset.
func swapAt(_ i: Int, _ j: Int)
Exchanges the byte values at the specified indices in this buffer’s memory.
func withContiguousMutableStorageIfAvailable<R>(_ body: (inout UnsafeMutableBufferPointer<UnsafeMutableRawBufferPointer.Element>) throws -> R) rethrows -> R?
func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<UnsafeMutableRawBufferPointer.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 buffer to instances of type T
.
typealias Element = UInt8
typealias Index = Int
typealias Iterator = UnsafeRawBufferPointer.Iterator
typealias SubSequence = Slice<UnsafeMutableRawBufferPointer>
static func allocate(count: Int) -> UnsafeMutableRawBufferPointer
func copyBytes(from source: UnsafeRawBufferPointer)