public void ShouldIncrementOccurrencesOnMultipleInserts() { var trie = new ArrayTrie(); trie.Insert("test"); trie.Insert("test"); var results = trie.Find("te").ToList(); Assert.AreEqual(1, results.Count); Assert.AreEqual(2, results[0].occurrences); }
public void ShouldFindStoredWord() { var trie = new ArrayTrie(); trie.Insert("test"); var results = trie.Find("te").Select(t => t.word).ToList(); Assert.AreEqual(1, results.Count); Assert.Contains("test", results); }
private void UpdateTags(TagAction action, IEnumerable <string> hashes, string tag) { WriteLocked(() => { foreach (var hash in hashes) { if (_previewModels.TryGetValue(hash, out var item)) { if (action == TagAction.Add) { item.Tags.Add(tag); _trie.Insert(tag); } else { item.Tags.Remove(tag); } } } }); }
public void Add(string tag) => _trie.Insert(tag);