_TinyArray
public struct _TinyArray<Element>
extension _TinyArray: RandomAccessCollection
extension _TinyArray: Equatable where Element: Equatable
extension _TinyArray: Hashable where Element: Hashable
extension _TinyArray: Sendable where Element: Sendable
TinyArray is a RandomAccessCollection optimised to store zero or one Element.
It supports arbitrary many elements but if only up to one Element is stored it does not allocate separate storage on the heap
and instead stores the Element inline.
-
Declaration
Swift
@usableFromInline enum Storageextension _TinyArray.Storage: RandomAccessCollectionextension _TinyArray.Storage: Equatable where Element: Equatableextension _TinyArray.Storage: Hashable where Element: Hashableextension _TinyArray.Storage: Sendable where Element: Sendable -
Declaration
Swift
@usableFromInline var storage: Storage
-
Declaration
Swift
public typealias Element = Element -
Declaration
Swift
public typealias Index = Int -
Declaration
Swift
@inlinable public func makeIterator() -> Iterator -
Declaration
Swift
public struct Iterator : IteratorProtocolextension _TinyArray.Iterator: Sendable where Element: Sendable -
Declaration
Swift
@inlinable public subscript(position: Int) -> Element { get } -
Declaration
Swift
@inlinable public var startIndex: Int { get } -
Declaration
Swift
@inlinable public var endIndex: Int { get } -
Declaration
Swift
@inlinable public init(_ elements: some Sequence<Element>) -
Declaration
Swift
@inlinable public init(_ elements: some Sequence<Result<Element, some Error>>) throws -
Declaration
Swift
@inlinable public init() -
Declaration
Swift
@inlinable public mutating func append(_ newElement: Element) -
Declaration
Swift
@inlinable public mutating func append(contentsOf newElements: some Sequence<Element>) -
Declaration
Swift
@discardableResult @inlinable public mutating func remove(at index: Int) -> Element -
Declaration
Swift
@inlinable public mutating func removeAll(where shouldBeRemoved: (Element) throws -> Bool) rethrows -
Declaration
View on GitHub