public void Print() { while (Head != null) { Console.WriteLine(Head.data); Head = Head.Next; } }
public void Clear() { Head = null; //while (Head != null) //{ // Head = Head.Next; //} cnt = 0; }
public stackNode <T> Pop() { if (Head == null) { return(null); } stackNode <T> popNode = Head; Head = Head.Next; cnt--; return(popNode); }
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); }
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++; }