public T PopBack() { if (Empty) { throw new Exception("Queue empty."); } LinkedElement <T> temp = first; while (temp.getParent() != last) { if (temp.getParent() == null) { last = null; first = null; return(temp.valor); } temp = temp.getParent(); } temp.setParent(null); LinkedElement <T> temp2 = last; last = temp; return(temp2.valor); }
public void Push(T valor) { if (valor == null) { throw new Exception("Invalid value: null"); } LinkedElement <T> element = new LinkedElement <T>(valor); element.setParent(top); top = element; }
public void Enter(T valor) { if (valor == null) { throw new Exception("Invalid value: null"); } LinkedElement <T> element = new LinkedElement <T>(valor); if (first == null) { first = element; } if (last != null) { last.setParent(element); } last = element; }
public void PushFront(T valor) { if (valor == null) { throw new Exception("Invalid value: null"); } LinkedElement <T> element = new LinkedElement <T>(valor); if (first != null) { element.setParent(first); } else { last = element; } first = element; }