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 })
-
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>
-
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.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 -
Declaration
Swift
public subscript(bounds: Range<Index>) -> SubSequence
Return Value
A slice of dictionary with
bounds
-
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 whetherkey
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 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 func suffix(from start: Index) -> SubSequence
Parameters
from
the from index for this slice
Return Value
A slice of dictionary from
from
-
A description of this dictionary
Declaration
Swift
public var description: String