ManagedBuffer
A class whose instances contain a property of type Header
and raw storage for an array of Element
, whose size is determined at instance creation.
class ManagedBuffer<Header, Element>
Note that the Element
array is suitably-aligned raw memory. You are expected to construct and—if necessary—destroy objects there yourself, using the APIs on UnsafeMutablePointer<Element>
. Typical usage stores a count and capacity in Header
and destroys any live elements in the deinit
of a subclass.
Citizens in Swift
Members
class func create(minimumCapacity: Int, makingHeaderWith: (ManagedBuffer<Header, Element>) throws -> Header
) rethrows -> ManagedBuffer<Header, Element> Create a new instance of the most-derived class, calling
factory
on the partially-constructed object to generate an initialHeader
.var capacity: Int
The actual number of elements that can be stored in this object.
var header: Header
The stored
Header
instance.func withUnsafeMutablePointerToElements<R>((UnsafeMutablePointer<Element>) throws -> R
) rethrows -> R Call
body
with anUnsafeMutablePointer
to theElement
storage.func withUnsafeMutablePointerToHeader<R>((UnsafeMutablePointer<Header>) throws -> R
) rethrows -> R Call
body
with anUnsafeMutablePointer
to the storedHeader
.func withUnsafeMutablePointers<R>((UnsafeMutablePointer<Header>, UnsafeMutablePointer<Element>) throws -> R
) rethrows -> R Call
body
withUnsafeMutablePointer
s to the storedHeader
and rawElement
storage.