Initializer

init(minimumCapacity:)

Creates an empty dictionary with preallocated space for at least the specified number of elements.

Declaration

init(minimumCapacity: Int)

Parameters

minimumCapacity

The minimum number of key-value pairs that the newly created dictionary should be able to store without reallocating its storage buffer.

Discussion

Use this initializer to avoid intermediate reallocations of a dictionary’s storage buffer when you know how many key-value pairs you are adding to a dictionary after creation.

See Also

Creating a Dictionary

init()

Creates an empty dictionary.

init<S>(uniqueKeysWithValues: S)

Creates a new dictionary from the key-value pairs in the given sequence.

init<S>(S, uniquingKeysWith: (Value, Value) -> Value)

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.

init<S>(grouping: S, by: (S.Element) -> Key)

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.