public override void Enqueue(object item) { Node newItem = WrapObject(item); if (IsEmpty()) {front = back = newItem;} else { back.next = newItem; back = newItem; } this.Count++; }
public override object Dequeue() { Node item; if (IsEmpty()) {throw new EmptyQueueException("Queue is empty, cannot dequeue. ");} item = front; if (this.Count == 1) {front = back = null;} else { front = front.next; item.ClearLink(); } this.Count--; return item; }
/** Creates a copy of the node... */ private Node CopyNode(Node old) { return new Node(old.data); }
public LLQueue() { this.Count = 0; front = back = null; }
public void ClearLink(){ this.next = null; }
public Node(object item){ this.data = item; this.next = null; }
public Node(){ this.data = null; this.next = null; }