SortedArray
public struct SortedArray <Element: Comparable>:
RandomAccessCollectionWrapping,
SortedCollectionWrapping
extension SortedArray: Equatable
extension SortedArray: Additive
extension SortedArray: Monoid
extension SortedArray: ExpressibleByArrayLiteral
extension SortedArray: Hashable where Element: Hashable
Array that keeps itself sorted.
-
Underlying storage of elements contained herein.
Declaration
Swift
public var base: [Element]
-
Create an empty
SortedArray.Declaration
Swift
public init() -
Creates an empty
SortedArraytype with preallocated space for at least the specified number of elements.Declaration
Swift
public init(minimumCapacity: Int) -
Create a
SortedArraywith the given sequence ofelements.Declaration
Swift
public init<S>(_ elements: S) where Element == S.Element, S : Sequence -
Create a
SortedArraywith the given collection of presorted elements.Warning
You must be certain thatpresortedis sorted, otherwise undefined behavior is certain.Declaration
Swift
public init<C>(presorted: C) where Element == C.Element, C : Collection -
Create a
SortedArraywith the given array of presorted elements.Warning
You must be certain thatpresortedis sorted, otherwise undefined behavior is certain.Declaration
Swift
public init(presorted: [Element]) -
Creates a
SortedArraywith the contents of another one.Declaration
Swift
public init(_ sorted: SortedArray)
-
Remove the given
element, if it is contained herein.Todo
Makethrowsinstead of returning silently.Declaration
Swift
public mutating func remove(_ element: Element) -
Insert the given
element.Complexity
O(n)Declaration
Swift
public mutating func insert(_ element: Element) -
Insert the contents of another sequence of
T.Declaration
Swift
public mutating func insert<S>(contentsOf elements: S) where Element == S.Element, S : Sequence -
Reserves the amount of memory to store the given
minimumCapacityof elements.Declaration
Swift
public mutating func reserveCapacity(_ minimumCapacity: Int) -
Appends the given
element.Warning
This element must be greater or equal to the current maximum, otherwise there will be undefined behavior ahead.Declaration
Swift
public mutating func append(guaranteedMax element: Element) -
Declaration
Swift
public func index(of element: Element) -> Int?Return Value
Index for the given
element, if it exists. Otherwise,nil. -
Declaration
Swift
public subscript(bounds: Range<Base.Index>) -> Slice<Base> { get }Return Value
The slice of the
SortedArrayfor the givenbounds.
-
Declaration
Swift
public static var zero: SortedArray { get }Return Value
Empty
SortedArray. -
Declaration
Swift
public static func + <T>(lhs: SortedArray<T>, rhs: SortedArray<T>) -> SortedArray<T> where T : ComparableReturn Value
SortedArraywith the contents of twoSortedArrayvalues.
-
Declaration
Swift
public static var identity: SortedArray<Element> { get }Return Value
Empty
SortedArray. -
Declaration
Swift
public static func <> (lhs: SortedArray<Element>, rhs: SortedArray<Element>) -> SortedArray<Element>Return Value
Composition of two of the same
Semigrouptype values.
-
Declaration
Swift
public init(arrayLiteral elements: Element...)Return Value
Create a
SortedArraywith an array literal.
View on GitHub
Install in Dash
SortedArray Structure Reference