Beispiel #1
0
 /// <summary>Print the pre-post entry.</summary>
 /// <remarks>Print the pre-post entry.</remarks>
 public virtual void Print(int indent)
 {
     for (int i = 0; i < indent; i++)
     {
         ConsoleSurrogate.Write(" ");
     }
     ConsoleSurrogate.WriteLine("pre-post: " + src + "  " + dest);
 }
Beispiel #2
0
 /// <summary>Print the key and rank only, not the rest.</summary>
 /// <remarks>Print the key and rank only, not the rest.</remarks>
 public virtual void PrintKey(int indent)
 {
     for (int i = 0; i < indent; i++)
     {
         ConsoleSurrogate.Write(" ");
     }
     ConsoleSurrogate.WriteLine("key: " + key + " " + rank);
 }
 /// <summary>Prints the key stack.</summary>
 /// <remarks>Prints the key stack.</remarks>
 public virtual void Print()
 {
     ConsoleSurrogate.WriteLine("Key stack " + keyTop);
     for (int i = 0; i < keyTop; i++)
     {
         keyStack[i].PrintKey(0);
     }
 }
        /// <summary>Push a key in the stack.</summary>
        /// <remarks>
        /// Push a key in the stack.
        /// Keep the highest rank keys at the bottom.
        /// </remarks>
        public virtual void PushKey(Key key)
        {
            if (key == null)
            {
                ConsoleSurrogate.WriteLine("push null key");
                return;
            }
            int i;

            for (i = keyTop; i > 0; i--)
            {
                if (key.rank > keyStack[i - 1].rank)
                {
                    keyStack[i] = keyStack[i - 1];
                }
                else
                {
                    break;
                }
            }
            keyStack[i] = key;
            keyTop++;
        }