예제 #1
0
 public void UpdateStackDisplay()
 {
     textBox2.Text = "";
     for (int i = 0; i < currentStack.GetCount(); i++)
     {
         textBox2.Text += "[" + (i + 1) + "]             ->        " + currentStack.GetElementOnNumber(i) + "\r\n";
     }
 }
예제 #2
0
        //Use my Stack class.
        public ListStack(Stack b)
        {
            listStack = new List<int>();    //Constructor for the List.
            stackPointer = 0;

            if (b != null)
            {
                int pointer2;
                int i = 0;

                int[] array = new int[10];

                pointer2 = b.GetCount();
                if (pointer2 > 0)
                {
                    i = 1;
                }

                while (pointer2 > 0)
                {
                    array[i] = b.Pop();
                    pointer2--;
                    i++;
                }
                i--;
                while (i > 0)
                {
                    this.Push(array[i]);
                    i--;
                }
            }
        }
예제 #3
0
        public ArrayStack(Stack b)
        {
            arrayStack = new int[10];   //Tis the the Array where the Values will be stored. Max 10 items.
            Pointer = 0;    //A pointer to keep track of where to Pop or Push the next Value.

            if (b != null)
            {
                int pointer2;
                int i = 0;

                int[] array = new int[10];

                pointer2 = b.GetCount();
                if (pointer2 > 0)
                {
                    i = 1;
                }

                while (pointer2 > 0)
                {
                    array[i] = b.Pop();
                    pointer2--;
                    i++;
                }
                i--;
                while (i > 0)
                {
                    this.Push(array[i]);
                    i--;
                }
            }
        }
예제 #4
0
        public MyListStack(Stack b)
        {
            linkedListStack = new LinkedList <int>();
            Pointer         = 0;

            if (b != null)
            {
                int pointer2;
                int i = 0;

                int[] array = new int[10];

                pointer2 = b.GetCount();
                if (pointer2 > 0)
                {
                    i = 1;
                }

                while (pointer2 > 0)
                {
                    array[i] = b.Pop();
                    pointer2--;
                    i++;
                }
                i--;
                while (i > 0)
                {
                    this.Push(array[i]);
                    i--;
                }
            }
        }
예제 #5
0
        public ArrayStack(Stack b)
        {
            arrayStack = new int[10];   //Tis the the Array where the Values will be stored. Max 10 items.
            Pointer = 0;    //A pointer to keep track of where to Pop or Push the next Value.

            if (b != null)
            {
                int pointer2;
                int i = 0;

                int[] array = new int[10];

                pointer2 = b.GetCount();
                if (pointer2 > 0)
                {
                    i = 1;
                }

                while (pointer2 > 0)
                {
                    array[i] = b.Pop();
                    pointer2--;
                    i++;
                }
                i--;
                while (i > 0)
                {
                    this.Push(array[i]);
                    i--;
                }
            }
        }
예제 #6
0
        public MyListStack(Stack b)
        {
            linkedListStack = new LinkedList<int>();
            Pointer = 0;

            if (b != null)
            {
                int pointer2;
                int i = 0;

                int[] array = new int[10];

                pointer2 = b.GetCount();
                if (pointer2 > 0)
                {
                    i = 1;
                }

                while (pointer2 > 0)
                {
                    array[i] = b.Pop();
                    pointer2--;
                    i++;
                }
                i--;
                while (i > 0)
                {
                    this.Push(array[i]);
                    i--;
                }
            }
        }
예제 #7
0
        public ListStack(Stack b)            //Use my Stack class.
        {
            listStack    = new List <int>(); //Constructor for the List.
            stackPointer = 0;

            if (b != null)
            {
                int pointer2;
                int i = 0;

                int[] array = new int[10];

                pointer2 = b.GetCount();
                if (pointer2 > 0)
                {
                    i = 1;
                }

                while (pointer2 > 0)
                {
                    array[i] = b.Pop();
                    pointer2--;
                    i++;
                }
                i--;
                while (i > 0)
                {
                    this.Push(array[i]);
                    i--;
                }
            }
        }
예제 #8
0
 public void EmptyStack(Stack stack)
 {
     //To clear the stack just Pop every item in the stack.
     int max = stack.GetCount();
     for (int i = 0;i < max; i++){
         stack.Pop();
     }
 }
예제 #9
0
        public void EmptyStack(Stack stack)
        {
            //To clear the stack just Pop every item in the stack.
            int max = stack.GetCount();

            for (int i = 0; i < max; i++)
            {
                stack.Pop();
            }
        }