예제 #1
0
 [Test] public void Test_Main()
 {
     ByteStack bs = new ByteStack();
     Assert.AreEqual(0, bs.Count);
     bs.Push((byte) 'a');
     Assert.AreEqual(1, bs.Count);
     byte b = bs.Pop();
     Assert.AreEqual(b, (byte)'a');
     Assert.AreEqual(0, bs.Count);
 }
예제 #2
0
 /// <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();
     }
 }