public override String ToString() { QueueElement iterator = first; StringBuilder builder = new StringBuilder(); builder.Append("["); if (iterator != null) { builder.Append(" "); builder.Append(iterator.GetPriority()); builder.Append(". "); builder.Append(iterator.GetData()); iterator = iterator.GetPrev(); while (iterator != null) { builder.Append(", "); builder.Append(iterator.GetPriority()); builder.Append(". "); builder.Append(iterator.GetData()); iterator = iterator.GetPrev(); } builder.Append(" "); } builder.Append("]"); return(builder.ToString()); }
public ICollection <T> ToList() { LinkedList <T> list = new LinkedList <T> (); QueueElement iterator = first; while (iterator != null) { list.AddLast(iterator.GetData()); iterator = iterator.GetPrev(); } return(list); }