auto dictionary = new DTrie!string(["Win", "hot"], ["Lose", "cold"]); assert(dictionary["Win"] == ["Lose"]); assert(dictionary["hot"] == ["cold"]); bool error_thrown = false; try { dictionary["won"]; } catch(KeyError e) { error_thrown = true; } assert(error_thrown);
auto dictionary = new DTrie!int(["one", "two"], [1, 2]); assert(dictionary["one"] == [1]); assert(dictionary["two"] == [2]); bool error_thrown = false; try { dictionary["three"]; } catch(KeyError e) { error_thrown = true; } assert(error_thrown);
Multiple strings are available
string[] keys = [ "すもーくちーず" ]; string[] values = [ "スモークチーズ" ]; auto dictionary = new DTrie!(string)(keys, values); assert(dictionary["すもーくちーず"] == ["スモークチーズ"]);