public int peek(stacks s) { if (!isEmpty(s)) { IndexArray idx = idxStack[(int)s]; return(array[idx.Current - 1]); } else { throw new EmptyStackException(); } }
public void push(stacks s, int el) { IndexArray idx = idxStack[(int)s]; if (!isFull(s)) { array[idx.Current] = el; idx.Current++; } else { throw new FullStackException(); } }
public int pop(stacks s) { IndexArray idx = idxStack[(int)s]; if (!isEmpty(s)) { int result = array[idx.Current - 1]; array[idx.Current] = 0; idx.Current--; return(result); } else { throw new EmptyStackException(); } }
public bool isFull(stacks s) { IndexArray idx = idxStack[(int)s]; return(idx.Current > idx.Last); }
public bool isEmpty(stacks s) { IndexArray idx = idxStack[(int)s]; return(idx.Current.Equals(idx.First)); }