/// <summary> /// Perform the given function on every element of the trie. Perl's map() operator. /// </summary> /// <param name="w">The function to call</param> /// <param name="data">Extra data to pass along to the function.</param> /// <param name="current">What node are we currently on?</param> protected void Traverse(TrieWalker w, object data, TrieNode current) { if (!w(current, data)) { return; } foreach (TrieNode e in current) { Traverse(w, data, e); } }
/// <summary> /// Searches for the specified key. If the key is found, walker points to the key within the Trie. If /// the key is not found, the walker points to the portion of the key that was found (if any). /// </summary> /// <param name="key">The key to find</param> /// <param name="walker">The walker used to locate the key (even if the key was not found)</param> /// <returns>True if the key was found, otherwise false.</returns> public bool TryFind(string key, out TrieWalker <T> walker) { walker = new TrieWalker <T>(_root); foreach (char c in key) { if (!walker.Next(c)) { return(false); } } return(true); }
/// <summary> /// Perform the given function on every element of the trie. Perl's map() operator. /// Don't keep track of the keys (slightly faster than the other Traverse() method). /// </summary> /// <param name="w">The function to call</param> /// <param name="data">Extra data to pass along to the function.</param> public void Traverse(TrieWalker w, object data) { Traverse(w, data, m_root); }
/// <summary> /// Perform the given function on every element of the trie. Perl's map() operator. /// </summary> /// <param name="w">The function to call</param> /// <param name="data">Extra data to pass along to the function.</param> /// <param name="current">What node are we currently on?</param> protected void Traverse(TrieWalker w, object data, TrieNode current) { if (! w(current, data)) { return; } foreach (TrieNode e in current) { Traverse(w, data, e); } }
public KeyStateTree(string name) { Name = name; _treeWalker = new TrieWalker <ICombination, KeyEventCommand>(_trie); _lastKeyDownNodeForAllUp = null; }