internal T Pop( ) { if (top != null && top.previous != null) { var tempTop = top; top = tempTop.previous; return(tempTop.data); } if (bottom != null) { top = null; bottom = null; return(bottom.data); } return(default(T)); }
internal void Push(T data) { var node = new SNode <T>(data); if (top == null) { this.top = node; } else { var tempTop = this.top; this.top = node; this.top.previous = tempTop; } if (bottom == null) { this.bottom = node; } }
public SNode(T data) { this.data = data; this.previous = null; }