/// <summary> /// Copy the keys from the sub-tree into an ArrayList. /// </summary> /// <param name="n"> </param> /// <param name="data"> </param> /// <param name="key"> </param> private bool CopyWalker(TrieNode n, object data, ByteStack key) { if (n.Value != null) { ArrayList al = (ArrayList)data; al.Add((byte[])key); if (al.Count >= m_maxResults) { return(false); } } return(true); }
/// <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> /// <param name="key">A stack holding the current key value</param> protected void Traverse(TrieKeyWalker w, object data, TrieNode current, ByteStack key) { if (!w(current, data, key)) { return; } foreach (TrieNode e in current) { key.Push(e.Byte); Traverse(w, data, e, key); key.Pop(); } }