Dictionary
extension Dictionary- 
                  
                  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. // [Int64: [Player]] let cursor = try Player.fetchCursor(db) let dictionary = try Dictionary(grouping: cursor, by: { $0.teamID })DeclarationSwift public init<C: Cursor>(grouping cursor: C, by keyForValue: (C.Element) throws -> Key) throws where Value == [C.Element]ParameterscursorA cursor of values to group into a dictionary. keyForValueA closure that returns a key for each element in the cursor. 
- 
                  
                  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. // [Int64: [Player]] let cursor = try Player.fetchCursor(db) let dictionary = try Dictionary( minimumCapacity: 100, grouping: cursor, by: { $0.teamID })DeclarationSwift public init<C: Cursor>(minimumCapacity: Int, grouping cursor: C, by keyForValue: (C.Element) throws -> Key) throws where Value == [C.Element]ParametersminimumCapacityThe minimum number of key-value pairs that the newly created dictionary should be able to store without reallocating its storage buffer. cursorA cursor of values to group into a dictionary. keyForValueA closure that returns a key for each element in the cursor. 
- 
                  
                  Creates a new dictionary from the key-value pairs in the given cursor. You use this initializer to create a dictionary when you have a cursor of key-value tuples with unique keys. Passing a cursor with duplicate keys to this initializer results in a fatal error. // [Int64: Player] let cursor = try Player.fetchCursor(db).map { ($0.id, $0) } let playerByID = try Dictionary(uniqueKeysWithValues: cursor)Precondition The cursor must not have duplicate keys.DeclarationSwift public init<C: Cursor>(uniqueKeysWithValues keysAndValues: C) throws where C.Element == (Key, Value)ParameterskeysAndValuesA cursor of key-value pairs to use for the new dictionary. Every key in keysAndValuesmust be unique.
- 
                  
                  Creates a new dictionary from the key-value pairs in the given cursor. You use this initializer to create a dictionary when you have a cursor of key-value tuples with unique keys. Passing a cursor with duplicate keys to this initializer results in a fatal error. // [Int64: Player] let cursor = try Player.fetchCursor(db).map { ($0.id, $0) } let playerByID = try Dictionary( minimumCapacity: 100, uniqueKeysWithValues: cursor)Precondition The cursor must not have duplicate keys.DeclarationSwift public init<C: Cursor>(minimumCapacity: Int, uniqueKeysWithValues keysAndValues: C) throws where C.Element == (Key, Value)ParametersminimumCapacityThe minimum number of key-value pairs that the newly created dictionary should be able to store without reallocating its storage buffer. keysAndValuesA cursor of key-value pairs to use for the new dictionary. Every key in keysAndValuesmust be unique.
 View on GitHub
View on GitHub Install in Dash
Install in Dash Dictionary Extension Reference
        Dictionary Extension Reference