The dictionary representation of the Trie data structure.
import dtrie;
auto dictionary = new DTrie!(T)(keys, values);
assert(dictionary[keys[0]] == [values[0]]);
Where T is the type of an element of values.
import dtrie;
auto dictionary = new DTrie!string(["Win", "hot"], ["Lose", "cold"]);
assert(dictionary["Win"] == ["Lose"]);
assert(dictionary["hot"] == ["cold"]);
dictionary["won"]; //KeyError
Multi-byte strings are available.
import dtrie;
string[] keys = [
"あけます", "あけます",
"あけました", "あけました",
];
string[] values = [
"開けます", "明けます",
"開けました", "明けました",
];
auto dictionary = new DTrie!(string)(keys, values);
//"あけます" is associated to "開けます" and "明けます"
assert(dictionary["あけます"] == ["開けます", "明けます"]);
//"あけました" is associated to "開けました" and "明けました"
assert(dictionary["あけました"] == ["開けました", "明けました"]);
- Running Tests
$dub test
- Generating documentations
$dub build --build=docs