示例#1
0
        public void push(int value)
        {
            stack_node new_node = new stack_node(value, head);

            head = new_node;
            Length++;
        }
示例#2
0
        public void print_stack()
        {
            stack_node temp = head;

            Console.Write("Head->");

            while (temp != null)
            {
                Console.Write(temp.value + " ");
                temp = temp.next;
            }
        }
示例#3
0
        public int pop()
        {
            if (Length < 1)
            {
                throw new System.ArgumentException("Cannot pop an empty stack!");
            }
            stack_node temp = head;

            head = temp.next;
            Length--;
            return(temp.value);
        }
示例#4
0
 public stack_node(int val, stack_node next_node)
 {
     value = val;
     next  = next_node;
 }
示例#5
0
 public Stack(int first)
 {
     head   = new stack_node(first);
     Length = 1;
 }