NominalElementDictionary
public struct NominalElementDictionary<Key, Value> where Key : Hashable
extension NominalElementDictionary : Collection
extension NominalElementDictionary : Sequence
extension NominalElementDictionary : CustomReflectable
extension NominalElementDictionary
: CustomStringConvertible, CustomDebugStringConvertible
extension NominalElementDictionary : Hashable where Value : Hashable
extension NominalElementDictionary : Equatable where Value : Equatable
extension NominalElementDictionary
: Decodable where Key : Decodable, Value : Decodable
extension NominalElementDictionary : Encodable
where Key : Encodable, Value : Encodable
A Dictionary with a nominal Element
type, that can conform to things.
-
The underlying Swift dictionary.
Declaration
Swift
public typealias Base = [Key : Value]
-
A view of a dictionary’s keys.
Declaration
Swift
public typealias Keys = Base.Keys
-
A view of a dictionary’s values.
Declaration
Swift
public typealias Values = Base.Values
-
The position of a key-value pair in a dictionary.
Declaration
Swift
public typealias Index = Base.Index
-
The underlying Swift Dictionary
Declaration
Swift
public var base: Base
-
The element type of a dictionary, just like a tuple containing an individual key-value pair, but nominal.
Declaration
Swift
public typealias Element = KeyValuePair<Key, Value>
-
Creates an empty dictionary.
Declaration
Swift
public init()
-
Creates an empty dictionary with preallocated space for at least the specified number of elements.
Declaration
Swift
public init(minimumCapacity: Int)
-
Creates a new dictionary from the key-value pairs in the given sequence.
Declaration
-
Creates a new dictionary from the key-value pairs in the given sequence, using a combining closure to determine the value for any duplicate keys.
Declaration
-
Creates a new dictionary whose keys are the groupings returned by the given closure and whose values are arrays of the elements that returned each key.
Declaration
-
Returns a new dictionary containing the key-value pairs of the dictionary that satisfy the given predicate.
Declaration
Swift
@available(swift 4.0) public func filter( _ isIncluded: (Element) throws -> Bool ) rethrows -> NominalElementDictionary
-
Accesses the value associated with the given key, producing
nil
when the value of a key not in the dictionary is read, and erasing the key ifnil
is written.Declaration
Swift
public subscript(key: Key) -> Value? { get set }
-
Accesses the value for
key
, ordefaultValue
no such key exists in the dictionary, on write first insertingkey
with valuedefaultValue
if it does not exist in the dictionary.Declaration
Swift
public subscript( key: Key, default defaultValue: @autoclosure () -> Value ) -> Value
-
Returns a new dictionary containing the keys of this dictionary with the values transformed by the given closure.
Declaration
Swift
public func mapValues<T>( _ transform: (Value) throws -> T ) rethrows -> NominalElementDictionary<Key, T>
-
Returns a new dictionary containing only the key-value pairs that have non-
nil
values as the result of transformation by the given closure.Declaration
Swift
public func compactMapValues<T>( _ transform: (Value) throws -> T? ) rethrows -> [Key : T]
-
Updates the value stored in the dictionary for the given key and returns the old value, or adds a new key-value pair if the key does not exist and returns nil .
Declaration
Swift
public mutating func updateValue( _ value: Value, forKey key: Key ) -> Value?
-
Merges the key-value pairs in the given sequence into the dictionary, using a combining closure to determine the value for any duplicate keys.
Declaration
-
Merges the given dictionary into this dictionary, using a combining closure to determine the value for any duplicate keys.
Declaration
Swift
public mutating func merge( _ other: Self, uniquingKeysWith combine: (Value, Value) throws -> Value ) rethrows
-
Creates a dictionary by merging key-value pairs in a sequence into the dictionary, using a combining closure to determine the value for duplicate keys.
Declaration
-
Creates a dictionary by merging the given dictionary into this dictionary, using a combining closure to determine the value for duplicate keys.
Declaration
Swift
public func merging( _ other: Self, uniquingKeysWith combine: (Value, Value) throws -> Value ) rethrows -> Self
-
Removes and returns the key-value pair at the specified index.
-
Removes the given key and its associated value from the dictionary.
Declaration
Swift
public mutating func removeValue(forKey key: Key) -> Value?
-
Removes all key-value pairs from the dictionary.
Declaration
Swift
public mutating func removeAll( keepingCapacity keepCapacity: Bool = false )
-
A collection containing just the keys of the dictionary.
Declaration
Swift
@available(swift 4.0) public var keys: Keys { get }
-
A collection containing just the values of the dictionary.
Declaration
Swift
@available(swift 4.0) public var values: Values { get set }
-
An iterator over the members of a
See moreNominalElementDictionary<Key, Value>
.Declaration
Swift
public struct Iterator : IteratorProtocol
-
Removes and returns the first key-value pair of the dictionary if the dictionary isn’t empty.
Declaration
Swift
public mutating func popFirst() -> Element?
-
The total number of key-value pairs that the dictionary can contain without allocating new storage.
Declaration
Swift
public var capacity: Int { get }
-
Reserves enough space to store the specified number of key-value pairs.
Declaration
Swift
public mutating func reserveCapacity(_ minimumCapacity: Int)
-
The position of the first element in a nonempty dictionary.
Declaration
Swift
public var startIndex: Index { get }
-
The dictionary’s “past the end” position—that is, the position one greater than the last valid subscript argument.
Declaration
Swift
public var endIndex: Index { get }
-
Returns the position immediately after the given index.
-
Replaces the given index with its successor.
Declaration
Swift
public func formIndex(after i: inout Index)
-
Returns the index for the given key.
Declaration
Swift
public func index(forKey key: Key) -> Index?
-
Accesses the key-value pair at the specified position.
-
The number of key-value pairs in the dictionary.
Declaration
Swift
public var count: Int { get }
-
A Boolean value that indicates whether the dictionary is empty.
Declaration
Swift
public var isEmpty: Bool { get }
-
Returns an iterator over the dictionary’s key-value pairs.
Declaration
Swift
public func makeIterator() -> Iterator
-
A mirror that reflects the dictionary.
Declaration
Swift
public var customMirror: Mirror { get }
-
A string that represents the contents of the dictionary.
Declaration
Swift
public var description: String { get }
-
A string that represents the contents of the dictionary, suitable for debugging.
Declaration
Swift
public var debugDescription: String { get }
-
Creates a new dictionary by decoding from the given decoder.
Declaration
Swift
public init(from decoder: Decoder) throws
-
Encodes the contents of this dictionary into the given encoder.
Declaration
Swift
public func encode(to encoder: Encoder) throws