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: IntReturn Value
The number of stored key/value pairs
-
Declaration
Swift
public var startIndex: IndexReturn Value
The start index
-
Declaration
Swift
public var endIndex: IndexReturn 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: BoolReturn 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>) -> SubSequenceReturn Value
A slice of dictionary with
bounds
-
Checks and sees if
keyis in this dictionary. This does not evaluate the value being stored.Declaration
Swift
public func contains(_ key: Key) -> BoolParameters
keyThe key to check for.
Return Value
A
Boolindicating whetherkeyis being stored. -
Creates an iterator for this dictionary. Forces evaulation of all elements.
Declaration
Swift
public func makeIterator() -> IteratorReturn Value
An iterator for this collection.
-
Declaration
Swift
public func prefix(upTo end: Index) -> SubSequenceParameters
upTothe end index for this slice
Return Value
A slice of dictionary up to
upTo -
Declaration
Swift
public func prefix(through position: Index) -> SubSequenceParameters
throughthe through index for this slice
Return Value
A slice of dictionary through
upTo -
Declaration
Swift
public func suffix(from start: Index) -> SubSequenceParameters
fromthe from index for this slice
Return Value
A slice of dictionary from
from
-
A description of this dictionary
Declaration
Swift
public var description: String
DiscordLazyDictionary Structure Reference