DiscordLazyDictionary

public struct DiscordLazyDictionary<K: Hashable, V> : ExpressibleByDictionaryLiteral, Collection

A value-lazy dictionary

To store a lazy value into the dictionary:

var dict = [2: 4] as DiscordLazyDictionary

dict[lazy: 24] = .lazy({ 2343 + 2343 })
  • Key

    The key type.

    Declaration

    Swift

    public typealias Key = K
  • The value type.

    Declaration

    Swift

    public typealias Value = V
  • The index type.

    Declaration

    Swift

    public typealias Index = DiscordLazyDictionaryIndex<Key, Value>
  • The iterator type.

    Declaration

    Swift

    public typealias Iterator = Dictionary<Key, Value>.Iterator
  • The subsequence type.

    Declaration

    Swift

    public typealias SubSequence =  Slice<DiscordLazyDictionary<Key, Value>>
  • Declaration

    Swift

    public var count: Int

    Return Value

    The number of stored key/value pairs

  • Declaration

    Swift

    public var startIndex: Index

    Return Value

    The start index

  • Declaration

    Swift

    public var endIndex: Index

    Return Value

    The end index

  • Declaration

    Swift

    public var first: Iterator.Element?

    Return Value

    The first key/value pair stored in the dictionary.

  • Declaration

    Swift

    public var isEmpty: Bool

    Return Value

    A Bool indicating whether this dictionary is empty

  • Used to getset the value stored at key. This will force evaluation if the value hasn’t been computed yet. Can be used to set an already computed value.

    Declaration

    Swift

    public subscript(key: Key) -> Value?

    Return Value

    An optional containing the value at key, or nil if that key is not in the dictionary

  • Used to getset the DiscordLazyValue stored at key. Can be used to set a lazy value.

    Declaration

    Swift

    public subscript(lazy key: Key) -> DiscordLazyValue<V>?

    Return Value

    An optional containing the DiscordLazyValue at key, or nil if that key is not in the dictionary

  • Used to get the keyvalue pair stored at position.

    Declaration

    Swift

    public subscript(position: Index) -> Iterator.Element

    Return Value

    An optional containing the keyvalue pair at key, or nil if that key is not in the dictionary

  • Declaration

    Swift

    public subscript(bounds: Range<Index>) -> SubSequence

    Return Value

    A slice of dictionary with bounds

  • ExpressibleByDictionaryLiteral conformance.

    Declaration

    Swift

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

    Parameters

    dictionaryLiteral

    Array of keyvalue pairs.

  • Checks and sees if key is in this dictionary. This does not evaluate the value being stored.

    Declaration

    Swift

    public func contains(_ key: Key) -> Bool

    Parameters

    key

    The key to check for.

    Return Value

    A Bool indicating whether key is being stored.

  • Creates an iterator for this dictionary. Forces evaulation of all elements.

    Declaration

    Swift

    public func makeIterator() -> Iterator

    Return Value

    An iterator for this collection.

  • Declaration

    Swift

    public func index(after i: Index) -> Index

    Parameters

    after

    The index for which we want the successor to

    Return Value

    The index after the specified index.

  • Declaration

    Swift

    public func prefix(upTo end: Index) -> SubSequence

    Parameters

    upTo

    the end index for this slice

    Return Value

    A slice of dictionary up to upTo

  • Declaration

    Swift

    public func prefix(through position: Index) -> SubSequence

    Parameters

    through

    the through index for this slice

    Return Value

    A slice of dictionary through upTo

  • Declaration

    Swift

    public mutating func removeValue(forKey key: Key) -> Value?

    Parameters

    forKey

    the key for the value being removed

    Return Value

    an optional containing the value stored at key, or nil if key wasn’t stored in this dictionary

  • Declaration

    Swift

    public func suffix(from start: Index) -> SubSequence

    Parameters

    from

    the from index for this slice

    Return Value

    A slice of dictionary from from

  • Updates the values stored in self with values stored in other, without evaluating the value.

    Declaration

    Swift

    public mutating func updateValues(withOtherDict other: DiscordLazyDictionary<Key, Value>)

    Parameters

    withOtherDict

    The values to update with.

  • A description of this dictionary

    Declaration

    Swift

    public var description: String