public MyStackEnumerator(MyStack <T> q) { Collection = new T[q.Count]; q.CopyTo(Collection, 0); curIndex = -1; curElem = default(T); }
public MyLinkedStack(MyStack <T> s) { Count = s.Count; T[] data = new T[Count]; s.CopyTo(data, 0); Node <T> n = new Node <T>(data[0]); for (int i = 1; i < Count; i++) { n.next = new Node <T>(data[i]); n.next.prev = n; n = n.next; } Top = n; }