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
true
iff an element of typee
can be appended toself
.Declaration
Swift
public func canAppendElement(ofType e: TypeID) -> Bool
-
Returns the result of invoking
body
on a typed alias ofself
, ifself.canStoreElement(ofType: Type<Element>.id)
; returnsnil
otherwise.Declaration
Swift
public mutating func mutate<Element, R>( ifElementType _: Type<Element>, _ body: (_ me: inout ArrayBuffer<Element>)->R ) -> R?
-
Returns the result of invoking
body
on 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 ifsrc
is not dispatched by aDispatch
or 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
self
without reallocation, provided its representation is not shared with other instances.Declaration
Swift
public var capacity: Int { get }
-
Accesses
self
as anArrayBuffer<Element>
ifElement.self == elementType
.- Writing
nil
removes 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
self
as anArrayBuffer<Element>
.Requires
Element.self == elementType
.Declaration
Swift
public subscript<Element>(existingElementType _: Type<Element>) -> ArrayBuffer<Element> { get set }
-
Accesses
self
as 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