/** Pops off the top item from stack */ public override object Pop() { if (IsEmpty()) throw new EmptyStackException("Nothing in LLStack. "); Node temp = top; if (top.next != null) {top = top.next;} else top = bot = null; temp.next = null; return temp; }
/** Stores an item on the top of the stack. */ public override void Push(object item) { Node newItem = WrapObject(item); Node temp = null; if (IsEmpty()) {top = bot = newItem; } else { temp = top; top = newItem; top.next = temp; } }
public Node(){ this.data = null; this.next = null; }
public LLStack(){ top = null; bot = null; }
public void ClearLink(){ this.next = null; }