SwiftTrie
A Swift package that provides a Trie data structure that allow efficient searches of values that map from prefixed keys or non-prefixed key substrings.
Minimum Requirements
- Swift 5.8
Installation
SwiftTrie can be integrated as an Xcode project target or a Swift package target.
Xcode Project Target
- Go to
File->Add Package Dependencies. - Type https://github.com/tyiu/swift-trie.git into the search field.
- Select
swift-triefrom the search results. - Select
Up to Next Major Versionstarting from the latest release as the dependency rule. - Ensure your project is selected next to
Add to Project. - Click
Add Package. - On the package product dialog, add
SwiftTrieto your target and clickAdd Package.
Swift Package Target
In your Package.swift file:
- Add the SwiftTrie package dependency to https://github.com/tyiu/swift-trie.git
- Add
SwiftTrieas a dependency on the targets that need to use the SDK.
let package = Package(
// ...
dependencies: [
// ...
.package(url: "https://github.com/tyiu/swift-trie.git", .upToNextMajor(from: "0.1.0"))
],
targets: [
.target(
// ...
dependencies: ["SwiftTrie"]
),
.testTarget(
// ...
dependencies: ["SwiftTrie"]
)
]
)
Usage
See TrieTests.swift for an example of how to use SwiftTrie.