A Thread Safe Dictionary
Collection
Protocol and also has all the relevant subscript
overrides which means you can use it just like a normal dictionary.Hashable
so now ThreadSafeDictionary
can be used with any key that conforms to the Hashable
protocol.1. Normal Dictionary Usage:
let dict = [String: A]()
let value = dict["hello"]
print(value)
2. ThreadSafeDictionary Usage
let dict = ThreadSafeDictionary<String,A>()
let value = dict["hello"]
print(value)
where A is any custom class
you can even do a for each like a normal dictionary
dict.forEach { (key, value) in
// your handling
}
So just by a single line change , you can enjoy benefits of thread safety and a swift implementation of a dictionary.
Guys this is being actively tested and used , will push commits if i face any issues , feel free to post issues if you find any.
Feels good to be back after a while