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

            stackNode <T> popNode = Head;

            Head = Head.Next;

            cnt--;

            return(popNode);
        }
Beispiel #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);
        }
Beispiel #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++;
        }