public ADTSortedList <T> InsertSorted(T t) { Node pom = this.Head; Node n = new ADTList <T> .Node(t); ADTSortedList <T> result = null; if (pom == null) { result = this.AddFirst(t) as ADTSortedList <T>; } else { while (pom != null) { if (n.Data.CompareTo(pom.Data) < 0) { n.Next = pom; n.Previous = pom.Previous; pom.Previous = n; if (n.Previous != null) { n.Previous.Next = n; } else { this.Head = n; } this.Count++; result = this; break; } else { pom = pom.Next; } } if (pom == null) { result = this.AddLast(t) as ADTSortedList <T>; } } return(result); }
public ADTQueue() { elements = new ADTList <T>(); }