AnyArrayBuffer
public struct AnyArrayBuffer<Dispatch> where Dispatch : AnyObject
A resizable, value-semantic buffer of homogenous elements of statically-unknown type.
-
Undocumented
Declaration
Swift
public typealias Storage = AnyArrayStorage -
A bounded contiguous buffer comprising all of
self‘s storage.Declaration
Swift
public var storage: AnyArrayBuffer<Dispatch>.Storage? -
A “vtable” of functions implementing type-erased operations that depend on the Element type.
Declaration
Swift
public let dispatch: Dispatch -
Undocumented
Declaration
Swift
public init<Element>(storage: ArrayStorage<Element>, dispatch: Dispatch) -
Creates a buffer with elements from
src.Declaration
Swift
public init(_ src: AnyArrayBuffer) -
Returns
trueiff an element of typeecan be appended toself.Declaration
Swift
public func canAppendElement(ofType e: TypeID) -> Bool -
Returns the result of invoking
bodyon a typed alias ofself, ifself.canStoreElement(ofType: Type<Element>.id); returnsnilotherwise.Declaration
Swift
public mutating func mutate<Element, R>( ifElementType _: Type<Element>, _ body: (_ me: inout ArrayBuffer<Element>)->R ) -> R? -
Returns the result of invoking
bodyon a typed alias ofself.Requires
self.elementType == Element.self.Declaration
Swift
@available(*, deprecated, message: "use subscript(unsafelyAssumingElementType:﹚ instead.") public mutating func unsafelyMutate<Element, R>( assumingElementType _: Type<Element>, _ body: (_ me: inout ArrayBuffer<Element>)->R ) -> R -
Creates an instance containing the same elements as
src, failing ifsrcis not dispatched by aDispatchor a subclass thereof.Declaration
Swift
public init?<OtherDispatch>(_ src: AnyArrayBuffer<OtherDispatch>) where OtherDispatch : AnyObject -
Creates an instance containing the same elements as
src.Requires
src.dispatch is Dispatch.Type.Declaration
Swift
public init<OtherDispatch>(unsafelyCasting src: AnyArrayBuffer<OtherDispatch>) where OtherDispatch : AnyObject -
The number of stored elements.
Declaration
Swift
public var count: Int { get } -
The number of elements that can be stored in
selfwithout reallocation, provided its representation is not shared with other instances.Declaration
Swift
public var capacity: Int { get } -
Accesses
selfas anArrayBuffer<Element>ifElement.self == elementType.- Writing
nilremoves all elements ofself. - Where
Element.self != elementType:- reading returns
nil. - writing changes the type of elements stored in
self.
- reading returns
Declaration
Swift
public subscript<Element>(elementType _: Type<Element>) -> ArrayBuffer<Element>? { get set } - Writing
-
Accesses
selfas anArrayBuffer<Element>.Requires
Element.self == elementType.Declaration
Swift
public subscript<Element>(existingElementType _: Type<Element>) -> ArrayBuffer<Element> { get set } -
Accesses
selfas anArrayBuffer<Element>unsafely assumingElement.self == elementType.Requires
self.storage!.isUsable(forElementType: Type<Element>).Declaration
Swift
public subscript<Element>(unsafelyAssumingElementType _: Type<Element>) -> ArrayBuffer<Element> { get set }
-
Creates an instance containing the same elements as
src.Declaration
Swift
public init<Element>(_ src: ArrayBuffer<Element>) -
Creates an instance containing the same elements as
src.Declaration
Swift
public init<OtherDispatch>(_ src: AnyArrayBuffer<OtherDispatch>) where OtherDispatch : AnyObject
View on GitHub
AnyArrayBuffer Structure Reference