mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Make OrderedDictionary keys generic
This commit is contained in:
parent
4e8e41c327
commit
1357449dcc
2 changed files with 8 additions and 11 deletions
|
@ -11,7 +11,7 @@ import UIKit
|
|||
// as immutable, once configured.
|
||||
public class ImageEditorContents: NSObject {
|
||||
|
||||
public typealias ItemMapType = OrderedDictionary<ImageEditorItem>
|
||||
public typealias ItemMapType = OrderedDictionary<String, ImageEditorItem>
|
||||
|
||||
// This represents the current state of each item,
|
||||
// a mapping of [itemId : item].
|
||||
|
@ -72,7 +72,7 @@ public class ImageEditorContents: NSObject {
|
|||
|
||||
@objc
|
||||
public func items() -> [ImageEditorItem] {
|
||||
return itemMap.orderedValues()
|
||||
return itemMap.orderedValues
|
||||
}
|
||||
|
||||
@objc
|
||||
|
|
|
@ -4,16 +4,13 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
public class OrderedDictionary<ValueType>: NSObject {
|
||||
public class OrderedDictionary<KeyType: Hashable, ValueType> {
|
||||
|
||||
public typealias KeyType = String
|
||||
private var keyValueMap = [KeyType: ValueType]()
|
||||
|
||||
var keyValueMap = [KeyType: ValueType]()
|
||||
public var orderedKeys = [KeyType]()
|
||||
|
||||
var orderedKeys = [KeyType]()
|
||||
|
||||
public override init() {
|
||||
}
|
||||
public init() { }
|
||||
|
||||
// Used to clone copies of instances of this class.
|
||||
public init(keyValueMap: [KeyType: ValueType],
|
||||
|
@ -25,7 +22,7 @@ public class OrderedDictionary<ValueType>: NSObject {
|
|||
|
||||
// Since the contents are immutable, we only modify copies
|
||||
// made with this method.
|
||||
public func clone() -> OrderedDictionary<ValueType> {
|
||||
public func clone() -> OrderedDictionary<KeyType, ValueType> {
|
||||
return OrderedDictionary(keyValueMap: keyValueMap, orderedKeys: orderedKeys)
|
||||
}
|
||||
|
||||
|
@ -90,7 +87,7 @@ public class OrderedDictionary<ValueType>: NSObject {
|
|||
return orderedKeys.count
|
||||
}
|
||||
|
||||
public func orderedValues() -> [ValueType] {
|
||||
public var orderedValues: [ValueType] {
|
||||
var values = [ValueType]()
|
||||
for key in orderedKeys {
|
||||
guard let value = self.keyValueMap[key] else {
|
||||
|
|
Loading…
Reference in a new issue