Instance Subscriptswift 6.0.1Swift
subscript(_:)
Accesses the byte at the given offset in the memory region as a UInt8
value.
subscript(i: Int) -> UnsafeRawBufferPointer.Element { get }
Parameters
- i
The offset of the byte to access.
i
must be in the range0..<count
.
Other members in extension
Types
struct Iterator
An iterator over the bytes viewed by a raw buffer pointer.
Typealiases
Type members
init(UnsafeRawBufferPointer
) Creates a new buffer over the same memory as the given buffer.
init<T>(UnsafeBufferPointer<T>
) Creates a raw buffer over the contiguous bytes in the given typed buffer.
init<T>(UnsafeMutableBufferPointer<T>
) Creates a raw buffer over the contiguous bytes in the given typed buffer.
init(UnsafeMutableRawBufferPointer
) Creates a new buffer over the same memory as the given buffer.
init(rebasing: Slice<UnsafeRawBufferPointer>
) Creates a raw buffer over the same memory as the given raw buffer slice, with the indices rebased to zero.
init(rebasing: Slice<UnsafeMutableRawBufferPointer>
) Creates a raw buffer over the same memory as the given raw buffer slice, with the indices rebased to zero.
init(start: UnsafeRawPointer?, count: Int
) Creates a buffer over the specified number of contiguous bytes starting at the given pointer.
Instance members
var baseAddress: UnsafeRawPointer?
A pointer to the first byte of the buffer.
var count: Int
The number of bytes in the buffer.
var debugDescription: String
A textual representation of the buffer, suitable for debugging.
var endIndex: UnsafeRawBufferPointer.Index
The “past the end” position—that is, the position one greater than the last valid subscript argument.
var indices: UnsafeRawBufferPointer.Indices
var startIndex: UnsafeRawBufferPointer.Index
Always zero, which is the index of the first byte in a nonempty buffer.
subscript(Range<Int>
) -> UnsafeRawBufferPointer.SubSequence Accesses the bytes in the specified memory region.
func assumingMemoryBound<T>(to: T.Type
) -> UnsafeBufferPointer<T> Returns a typed buffer to the memory referenced by this buffer, assuming that the memory is already bound to the specified type.
func bindMemory<T>(to: T.Type
) -> UnsafeBufferPointer<T> Binds this buffer’s memory to the specified type and returns a typed buffer of the bound memory.
func deallocate(
) Deallocates the memory block previously allocated at this buffer pointer’s base address.
func load<T>(fromByteOffset: Int, as: 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: Int, as: T.Type
) -> T func loadUnaligned<T>(fromByteOffset: Int, as: T.Type
) -> T Returns a new instance of the given type, constructed from the raw memory at the specified offset.
func makeIterator(
) -> UnsafeRawBufferPointer.Iterator Returns an iterator over the bytes of this sequence.
func withContiguousStorageIfAvailable<R>((UnsafeBufferPointer<UnsafeRawBufferPointer.Element>) throws -> R
) rethrows -> R? func withMemoryRebound<T, E, Result>(to: T.Type, (UnsafeBufferPointer<T>)
throws Executes the given closure while temporarily binding the buffer to instances of type
T
.