SortedDictionary

public struct SortedDictionary<Key, Value> : DictionaryProtocol where Key : Comparable, Key : Hashable
extension SortedDictionary: Collection
extension SortedDictionary: BidirectionalCollection
extension SortedDictionary: RandomAccessCollection
extension SortedDictionary: ExpressibleByDictionaryLiteral
extension SortedDictionary: Zero
extension SortedDictionary: Equatable where Value: Equatable
extension SortedDictionary: Hashable where Value: Hashable

Ordered dictionary which has sorted keys.

Instance Properties

  • Sorted keys.

    Declaration

    Swift

    public var keys: SortedArray<Key>
  • Values contained herein, in order sorted by their associated keys.

    Declaration

    Swift

    public var values: [Value] { get }

Initializers

  • Create an empty SortedOrderedDictionary.

    Declaration

    Swift

    public init()
  • Creates an empty SortedDictionary type with preallocated space for at least the specified number of elements.

    Declaration

    Swift

    public init(minimumCapacity: Int)
  • Creates a SortedDictionary with a collection of (Key,Value) pairs.

    Warning

    You must be certain that presorted is sorted, otherwise undefined behavior is certain.

    Declaration

    Swift

    public init<C>(presorted: C) where C : Collection, C.Element == (Key, Value)
  • Create a SortedDictionary with the elements of a presorted OrderedDictionary.

    Warning

    You must be certain that presorted is sorted, otherwise undefined behavior is certain.

    Declaration

    Swift

    public init(presorted: OrderedDictionary<Key, Value>)
  • Creats a SortedDictionary with the contents of another SortedDictionary.

    Declaration

    Swift

    public init(_ sorted: SortedDictionary)

Subscripts

  • Declaration

    Swift

    public subscript(key: Key) -> Value? { get set }

    Return Value

    Value for the given key, if available. Otherwise, nil.

Instance Methods

  • Insert the given value for the given key. Order will be maintained.

    Declaration

    Swift

    public mutating func insert(_ value: Value, key: Key)
  • Insert the contents of another SortedDictionary value.

    Declaration

    Swift

    public mutating func insert(contentsOf sortedDictionary: SortedDictionary<Key, Value>)
  • Append the given value for the given guaranteedMax key.

    Warning

    You must be certain that presorted is sorted, otherwise undefined behavior is certain.

    Declaration

    Swift

    public mutating func append(_ value: Value, guaranteedMax key: Key)
  • Reserves the amount of memory required to store the given minimumCapacity of elements.

    Declaration

    Swift

    public mutating func reserveCapacity(_ minimumCapacity: Int)
  • Declaration

    Swift

    public func value(at index: Int) -> Value?

    Return Value

    Value at the given index, if present. Otherwise, nil.

Collection

  • Index after the given index.

    Declaration

    Swift

    public func index(after index: Int) -> Int
  • Start index.

    Declaration

    Swift

    public var startIndex: Int { get }
  • End index.

    Declaration

    Swift

    public var endIndex: Int { get }
  • Count.

    Declaration

    Swift

    public var count: Int { get }
  • Index before the given index.

    Declaration

    Swift

    public func index(before index: Int) -> Int
  • Declaration

    Swift

    public subscript(index: Int) -> (Key, Value) { get }

    Return Value

    Element at the given index.

  • Undocumented

    Declaration

    Swift

    public func min() -> (Key, Value)?
  • Undocumented

    Declaration

    Swift

    public func max() -> (Key, Value)?
  • Undocumented

    Declaration

    Swift

    public func sorted() -> [(Key, Value)]

ExpressibleByDictionaryLiteral

  • Create a SortedDictionary with a DictionaryLiteral.

    Declaration

    Swift

    public init(dictionaryLiteral elements: (Key, Value)...)
  • Declaration

    Swift

    public static var zero: SortedDictionary { get }

    Return Value

    A SortedDictionary with no elements.