Iterator
An iterator over the members of a Dictionary<Key, Value>.
@frozen struct IteratorAn iterator over the members of a Dictionary<Key, Value>.
@frozen struct Iteratorwhere Key:Hashableimport Swift@frozen struct Dictionary<Key, Value> where Key : HashableA collection whose elements are key-value pairs.
protocol Hashable : EquatableA type that can be hashed into a Hasher to produce an integer hash value.
init(dictionaryLiteral elements: (Key, Value)...) Creates a dictionary initialized with a dictionary literal.
var capacity: Int { get }The total number of key-value pairs that the dictionary can contain without allocating new storage.
var count: Int { get }The number of key-value pairs in the dictionary.
var customMirror: Mirror { get }A mirror that reflects the dictionary.
var debugDescription: String { get }A string that represents the contents of the dictionary, suitable for debugging.
var description: String { get }A string that represents the contents of the dictionary.
var endIndex: Dictionary<Key, Value>.Index { get }The dictionary’s “past the end” position—that is, the position one greater than the last valid subscript argument.
var isEmpty: Bool { get }A Boolean value that indicates whether the dictionary is empty.
var keys: Dictionary<Key, Value>.Keys { get }A collection containing just the keys of the dictionary.
var startIndex: Dictionary<Key, Value>.Index { get }The position of the first element in a nonempty dictionary.
var values: Dictionary<Key, Value>.Values { get set }A collection containing just the values of the dictionary.
subscript(key: Key) -> Value? { get set } Accesses the value associated with the given key for reading and writing.
subscript(position: Dictionary<Key, Value>.Index) -> Dictionary<Key, Value>.Element { get } Accesses the key-value pair at the specified position.
subscript(key: Key, default defaultValue: @autoclosure () -> Value) -> Value { get set } Accesses the value with the given key, falling back to the given default value if the key isn’t found.
func compactMapValues<T>(_ transform: (Value) throws -> T?) rethrows -> Dictionary<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.
func filter(_ isIncluded: (Dictionary<Key, Value>.Element) throws -> Bool) rethrows -> [Key : Value] Returns a new dictionary containing the key-value pairs of the dictionary that satisfy the given predicate.
func formIndex(after i: inout Dictionary<Key, Value>.Index) func index(after i: Dictionary<Key, Value>.Index) -> Dictionary<Key, Value>.Index func index(forKey key: Key) -> Dictionary<Key, Value>.Index? Returns the index for the given key.
func makeIterator() -> Dictionary<Key, Value>.Iterator Returns an iterator over the dictionary’s key-value pairs.
func mapValues<T>(_ transform: (Value) throws -> T) rethrows -> Dictionary<Key, T> Returns a new dictionary containing the keys of this dictionary with the values transformed by the given closure.
mutating func merge(_ other: [Key : Value], uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows Merges the given dictionary into this dictionary, using a combining closure to determine the value for any duplicate keys.
mutating func merge<S>(_ other: S, uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows where S : Sequence, S.Element == (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.
func merging(_ other: [Key : Value], uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows -> [Key : Value] Creates a dictionary by merging the given dictionary into this dictionary, using a combining closure to determine the value for duplicate keys.
func merging<S>(_ other: S, uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows -> [Key : Value] where S : Sequence, S.Element == (Key, Value) 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.
mutating func popFirst() -> Dictionary<Key, Value>.Element? Removes and returns the first key-value pair of the dictionary if the dictionary isn’t empty.
@discardableResult mutating func remove(at index: Dictionary<Key, Value>.Index) -> Dictionary<Key, Value>.Element Removes and returns the key-value pair at the specified index.
mutating func removeAll(keepingCapacity keepCapacity: Bool = false) Removes all key-value pairs from the dictionary.
@discardableResult mutating func removeValue(forKey key: Key) -> Value? Removes the given key and its associated value from the dictionary.
mutating func reserveCapacity(_ minimumCapacity: Int) Reserves enough space to store the specified number of key-value pairs.
@discardableResult mutating func updateValue(_ value: Value, forKey key: Key) -> Value? Updates the value stored in the dictionary for the given key, or adds a new key-value pair if the key does not exist.
@frozen struct IndexThe position of a key-value pair in a dictionary.
@frozen struct KeysA view of a dictionary’s keys.
@frozen struct ValuesA view of a dictionary’s values.
typealias SubSequence = Slice<Dictionary<Key, Value>>var customMirror: Mirror { get }A mirror that reflects the iterator.
mutating func next() -> (key: Key, value: Value)? Advances to the next element and returns it, or nil if no next element exists.
protocol Sendable : SendableMetatypeA thread-safe type whose values can be shared across arbitrary concurrent contexts without introducing a risk of data races. Values of the type may have no shared mutable state, or they may protect that state with a lock or by forcing it to only be accessed from a specific actor.
protocol CopyableA type whose values can be implicitly or explicitly copied.
protocol Escapableprotocol SendableMetatype : ~Copyable, ~EscapableA type whose metatype can be shared across arbitrary concurrent contexts without introducing a risk of data races. When a generic type T conforms to SendableMetatype, its metatype T.Type conforms to Sendable. All concrete types implicitly conform to the SendableMetatype protocol, so its primary purpose is in generic code to prohibit the use of isolated conformances along with the generic type.
protocol CustomReflectableA type that explicitly supplies its own mirror.
protocol IteratorProtocol<Element>A type that supplies the values of a sequence one at a time.