public T Pop() { if (top == null) { throw new OverflowException(); } var item = top.Value; top = top.Next; size--; return(item); }
public void Enqueue(T item) { var node = new SingleLinkNode <T>(item); if (tail == null) { head = tail = node; } else { tail.Next = node; tail = tail.Next; } size++; }
public T Dequeue() { if (head == null) { throw new OverflowException(); } T item = head.Value; head = head.Next; if (head == null) { tail = null; } size--; return(item); }
public LinkedStack() { top = null; size = 0; }
public void Push(T item) { top = new SingleLinkNode <T>(item, top); size++; }
public SingleLinkNode() { value = default(T); next = null; }
public SingleLinkNode(T value, SingleLinkNode <T> next) { this.value = value; this.next = next; }
public SingleLinkNode(T value) { this.value = value; next = null; }
public LinkedQueue() { head = null; tail = null; size = 0; }