init(rebasing:)
Creates a buffer over the same memory as the given buffer slice.
init(rebasing slice: Slice<UnsafeMutableBufferPointer<Element>>)
Parameters
- slice
The buffer slice to rebase.
The new buffer represents the same region of memory as slice
, but is indexed starting at zero instead of sharing indices with the original buffer. For example:
let buffer = returnsABuffer()
let n = 5
let slice = buffer[n...]
let rebased = UnsafeBufferPointer(rebasing: slice)
After rebasing slice
as the rebased
buffer, the following are true:
rebased.startIndex == 0
rebased[0] == slice[n]
rebased[0] == buffer[n]
rebased.count == slice.count