Iterator
An iterator for the elements in the buffer referenced by an UnsafeBufferPointer
or UnsafeMutableBufferPointer
instance.
@frozen struct Iterator
An iterator for the elements in the buffer referenced by an UnsafeBufferPointer
or UnsafeMutableBufferPointer
instance.
@frozen struct Iterator
import Swift
@frozen struct UnsafeBufferPointer<Element> where Element : ~Copyable
A nonowning collection interface to a buffer of elements stored contiguously in memory.
init(_ other: UnsafeMutableBufferPointer<Element>)
Creates an immutable typed buffer pointer referencing the same memory as the given mutable buffer pointer.
init(rebasing slice: Slice<UnsafeBufferPointer<Element>>)
Creates a buffer over the same memory as the given buffer slice.
init(rebasing slice: Slice<UnsafeMutableBufferPointer<Element>>)
Creates a buffer over the same memory as the given buffer slice.
init(start: UnsafePointer<Element>?, count: Int)
Creates a new buffer pointer over the specified number of contiguous instances beginning at the given pointer.
var baseAddress: UnsafePointer<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: UnsafeBufferPointer<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 }
Accesses the element at the specified position.
subscript(bounds: Range<Int>) -> Slice<UnsafeBufferPointer<Element>> { get }
Accesses a contiguous subrange of the buffer’s elements.
subscript(i: Int) -> Element { get }
Accesses the element at the specified position.
func deallocate()
Deallocates the memory block previously allocated at this buffer pointer’s base address.
func distance(from start: Int, to end: Int) -> Int
func extracting(_ bounds: Range<Int>) -> UnsafeBufferPointer<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>) -> UnsafeBufferPointer<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_) -> ()) -> UnsafeBufferPointer<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 makeIterator() -> UnsafeBufferPointer<Element>.Iterator
Returns an iterator over the elements of this buffer.
func withContiguousStorageIfAvailable<R>(_ body: (UnsafeBufferPointer<Element>) throws -> R) rethrows -> R?
func withMemoryRebound<T, E, Result>(to type: T.Type, _ body: (UnsafeBufferPointer<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 SubSequence = Slice<UnsafeBufferPointer<Element>>
protocol BitwiseCopyable
mutating func next() -> Element?
Advances to the next element and returns it, or nil
if no next element exists.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol Escapable
protocol IteratorProtocol<Element>
A type that supplies the values of a sequence one at a time.