DictionaryProtocol
public protocol DictionaryProtocol : Collection
Interface for Dictionary-like structures.
-
Key type.
Declaration
Swift
associatedtype Key : Hashable
-
Value type.
Declaration
Swift
associatedtype Value
-
Create an empty
DictionaryProtocol
value.Declaration
Swift
init()
-
Creates an empty
DictionaryProtocol
-conforming type with preallocated space for at least the specified number of elements.Declaration
Swift
init(minimumCapacity: Int)
-
Reserves the required amount of memory to store the given
minimumCapacity
of key-value pairs.Declaration
Swift
mutating func reserveCapacity(_ minimumCapacity: Int)
-
init(_:
Extension method_: ) -
init(_:
Extension method)
-
merge(with:
Extension method) Merge the contents of the given
dictionary
destructively into this one.Declaration
Swift
public mutating func merge(with dictionary: Self)
-
merged(with:
Extension method) Declaration
Swift
public func merged(with dictionary: Self) -> Self
Return Value
A new
Dictionary
with the contents of the givendictionary
mergedself
over those ofself
.
-
ensureValue(forKey:
Extension method) Ensure that an
RangeReplaceableCollection
-conforming type value exists for the givenkey
.Declaration
Swift
@inlinable public mutating func ensureValue(forKey key: Key)
-
safelyAppend(_:
Extension methodforKey: ) -
safelyAppend(contentsOf:
Extension methodforKey: )
-
safelyAndUniquelyAppend(_:
Extension methodforKey: )
-
ensureValue(forKey:
Extension method) Ensure that an
SetAlgebra
-conforming type value exists for the givenkey
.Declaration
Swift
@inlinable public mutating func ensureValue(forKey key: Key)
-
safelyInsert(_:
Extension methodforKey: ) -
safelyFormUnion(_:
Extension methodforKey: )
-
ensureValue(forKey:
Extension method) Ensure there is a value for a given
key
.Declaration
Swift
@inlinable public mutating func ensureValue(forKey key: Key)
-
merge(with:
Extension method) Merge the contents of the given
dictionary
destructively into this one.Warning
The value of a given key of the givendictionary
will override that of this one.Declaration
Swift
public mutating func merge(with dictionary: Self)
-
merged(with:
Extension method) Declaration
Swift
public mutating func merged(with dictionary: Self) -> Self
Return Value
A new
Dictionary
with the contents of the givendictionary
mergedself
over those ofself
.