public void ContainsKeyClear() { var trie = new StringTrie <bool> { { "ABC", false }, { "AB", false }, { "ADE", false }, { "ABCDE", false } }; trie.Clear(); Assert.False(trie.ContainsKey("ABC")); Assert.False(trie.ContainsKey("AB")); Assert.False(trie.ContainsKey("ADE")); Assert.False(trie.ContainsKey("ABCDE")); }
public SearchService() { var lines = File.ReadAllLines("./data/cities500.txt"); for (int i = 1; i < lines.Length - 1; i++) { var split = lines[i].Split('\t'); var place = new Place { Id = int.Parse(split[0]), Name = split[2], Latitude = float.Parse(split[4]), Longitude = float.Parse(split[5]), }; _tree.Add(new[] { float.Parse(split[4]), float.Parse(split[5]) }, place); // if already contained if (_trie.ContainsKey(split[2])) { var places = _trie[split[2]]; places.Add(place); } else { _trie.Add(split[2], new List <Place> { place }); } } }