public Queue <T> EnQueue(T value) { if (IsEmpty) // queue is empty { _first = _last = new Node <T>(value); } else { _last.InsertRight(value); _last = _last.RightNode; } return(this); }
public T DeQueue() { if (IsEmpty) { throw new InvalidOperationException("The queue is empty!"); } T result = _first.Data; Node <T> newFirst = _first.RightNode; if (newFirst != null) { newFirst.DeleteLeft(); _first = newFirst; } else { _first = _last = null; } return(result); }
public Queue() { _first = _last = null; }