Esempio n. 1
0
 public void Print()
 {
     while (Head != null)
     {
         Console.WriteLine(Head.data);
         Head = Head.Next;
     }
 }
Esempio n. 2
0
 public void Clear()
 {
     Head = null;
     //while (Head != null)
     //{
     //    Head = Head.Next;
     //}
     cnt = 0;
 }
Esempio n. 3
0
        public stackNode <T> Pop()
        {
            if (Head == null)
            {
                return(null);
            }

            stackNode <T> popNode = Head;

            Head = Head.Next;

            cnt--;

            return(popNode);
        }
Esempio n. 4
0
        public bool Contains(T Data)
        {
            bool          result   = false;
            stackNode <T> tempNode = Head;

            while (tempNode != null)
            {
                if (Compare(Data, tempNode.data))
                {
                    result = true;
                    break;
                }
                else
                {
                    tempNode = tempNode.Next;
                }
            }

            return(result);
        }
Esempio n. 5
0
        public void Push(T a_data)
        {
            if (Head == null)
            {
                this.Head = new stackNode <T>();

                this.Head.data = a_data;
                this.Head.Next = null;
            }
            else
            {
                stackNode <T> newNode = new stackNode <T>();
                newNode.data = a_data;

                stackNode <T> tempNode = Head;

                Head      = newNode;
                Head.Next = tempNode;
            }

            cnt++;
        }