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 type e can be appended to self.

    Declaration

    Swift

    public func canAppendElement(ofType e: TypeID) -> Bool
  • Returns the result of invoking body on a typed alias of self, if self.canStoreElement(ofType: Type<Element>.id); returns nil 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 of self.

    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 if src is not dispatched by a Dispatch 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 an ArrayBuffer<Element> if Element.self == elementType.

    • Writing nil removes all elements of self.
    • Where Element.self != elementType:
      • reading returns nil.
      • writing changes the type of elements stored in self.

    Declaration

    Swift

    public subscript<Element>(elementType _: Type<Element>) -> ArrayBuffer<Element>? { get set }
  • Accesses self as an ArrayBuffer<Element>.

    Requires

    Element.self == elementType.

    Declaration

    Swift

    public subscript<Element>(existingElementType _: Type<Element>) -> ArrayBuffer<Element> { get set }
  • Accesses self as an ArrayBuffer<Element> unsafely assuming Element.self == elementType.

    Requires

    self.storage!.isUsable(forElementType: Type<Element>).

    Declaration

    Swift

    public subscript<Element>(unsafelyAssumingElementType _: Type<Element>) -> ArrayBuffer<Element> { get set }

Available where Dispatch == AnyObject

  • 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