Awesome Dictionary is a pure Swift implementation of a persistent Dictionary, composed of a collection of codable (key, value) pairs, such that each possible key appears at most once in the collection. Instead of using hash tables, it uses a compressed trie representatioon. Unlike HAMT, and CHAMP, it does not hash the key, before inserting.
Add AwesomeDictionary to Package.swift and the appropriate targets
dependencies: [
.package(url: "https://github.com/pumperknickle/AwesomeDictionary.git", from: "0.0.1")
]
Run benchmarks
swift run -c release my-benchmark run results --cycles 1
Use AwesomeDictionary by including it in the imports of your swift file
import AwesomeDictionary
Create an empty generic mapping
let newMapping = Mapping<String, [[String]]>()
Use subscript to get the value of a key.
let value = newMapping["foo"]
When setting, a new structure is returned with the new key value pair inserted.
let modifiedMap = newMapping.setting(key: "foo", value: [["fooValue"]])
When deleting, a new structure is returned with the entry corresponding to the key deleted.
let modifiedMap = newMapping.deleting(key: "foo")
link |
Stars: 0 |
Last commit: 2 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics