Last active
December 26, 2020 20:12
-
-
Save ollieatkinson/8624aff80a038bf7853d40e67f8870b5 to your computer and use it in GitHub Desktop.
AnyDictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol AnyDictionary: Collection { | |
associatedtype Key: Hashable | |
associatedtype Keys | |
associatedtype Value | |
associatedtype Values | |
associatedtype Index | |
var keys: Keys { get } | |
var values: Values { get } | |
subscript(key: Key) -> Value? { get set } | |
subscript(key: Key, default defaultValue: @escaping @autoclosure () -> Value) -> Value { get set } | |
func index(forKey: Key) -> Index? | |
mutating func updateValue(_ value: Value, forKey key: Key) -> Value? | |
mutating func merge<S>(_ other: S, uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows where S : Sequence, S.Element == (Key, Value) | |
mutating func merge(_ other: [Key : Value], uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows | |
func merging<S>(_ other: S, uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows -> [Key : Value] where S : Sequence, S.Element == (Key, Value) | |
func merging(_ other: [Key : Value], uniquingKeysWith combine: (Value, Value) throws -> Value) rethrows -> [Key : Value] | |
mutating func remove(at index: Index) -> Element | |
mutating func removeValue(forKey key: Key) -> Value? | |
mutating func removeAll(keepingCapacity keepCapacity: Bool) | |
} | |
extension Dictionary: AnyDictionary { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment