public override bool Pop() { try { top = top.next; --len; } catch (NullReferenceException) { return(false); } return(true); }
public override string ToString() { string[] niz = new string[len]; string tmp = ""; StackElementList <T> podatak = top; for (int i = 0; i < len; ++i) { niz[len - i - 1] = podatak.data.ToString(); podatak = podatak.next; } for (int i = 0; i < len; ++i) { tmp += niz[i]; if (i != len - 1) { tmp += ", "; } } return(tmp); }
public StackList() { top = null; len = 0; }
public override void Clear() { top = null; len = 0; }
public override bool Push(T data) { top = new StackElementList <T>(data, top); ++len; return(true); }
public StackElementList(T data, StackElementList <T> next) { this.data = data; this.next = next; }
public StackElementList() { this.next = null; }
public StackElementList(T data) { this.data = data; this.next = null; }