/// <summary> /// Remove object from front of queue. /// </summary> /// <returns>Object at beginning of queue</returns> public object RemoveFront() { if (IsEmpty) { throw new QueueEmptyException(); } object toreturn = _front.o; _front = _front._next; _count--; return(toreturn); }
/// <summary> /// Remove object from end of queue. /// </summary> /// <returns>Object at end of queue</returns> public object RemoveEnd() { if (IsEmpty) { throw new QueueEmptyException(); } object toreturn = _back.o; _back = _back._prev; _count--; return(toreturn); }
/// <summary> /// Add object to end of queue /// </summary> /// <param name="o">object to add</param> public void AddEnd(object o) { if (IsEmpty) { DLnode dln = new DLnode(o, null, null); _front = dln; _back = dln; } else { DLnode dln = new DLnode(o, _back, null); _back._next = dln; _back = dln; } _count++; }
/// /// <param name="o">object to add</param> public void AddFront(object o) { if (IsEmpty) { DLnode dln = new DLnode(o, null, null); _front = dln; _back = dln; } else { DLnode dln = new DLnode(o, null, _front); _front._prev = dln; _front = dln; } _count++; }
public DLnode(object o, DLnode prev, DLnode next) { this.o = o; _prev = prev; _next = next; }