Instance Method


Removes all key-value pairs from the dictionary.


mutating func removeAll(keepingCapacity keepCapacity: Bool = false)



Whether the dictionary should keep its underlying buffer. If you pass true, the operation preserves the buffer capacity that the collection has, otherwise the underlying buffer is released. The default is false.


Calling this method invalidates all indices with respect to the dictionary.

Complexity: O(n), where n is the number of key-value pairs in the dictionary.

See Also

Removing Keys and Values

func filter((Dictionary<Key, Value>.Element) -> Bool) -> [Key : Value]

Returns a new dictionary containing the key-value pairs of the dictionary that satisfy the given predicate.

func removeValue(forKey: Key) -> Value?

Removes the given key and its associated value from the dictionary.

func remove(at: Dictionary<Key, Value>.Index) -> Dictionary<Key, Value>.Element

Removes and returns the key-value pair at the specified index.