public int peek() { int lastStackIndex = listOfStacks.Count - 1; StackPlate stack = getStack(lastStackIndex); return(stack.peek()); }
public int pop() { int lastStackIndex = listOfStacks.Count - 1; StackPlate stack = getStack(lastStackIndex); int val = stack.pop(); if (stack.isEmpty() && this.listOfStacks.Count > 1) { listOfStacks.RemoveAt(lastStackIndex); } return(val); }
public void push(int item) { StackPlate stack = getStack(listOfStacks.Count - 1); if (!stack.isFull()) { stack.push(item); } else { stack = new StackPlate(this.capacityStacks); stack.push(item); listOfStacks.Add(stack); } }
private int leftShif(int index) { int numberStacks = listOfStacks.Count; StackPlate prevStack = getStack(index); int result = prevStack.pop(); for (int i = index + 1; i < numberStacks; i++) { StackPlate stack = getStack(i); int val = stack.getBottom(); if (stack.isEmpty() && this.listOfStacks.Count > 1) { listOfStacks.RemoveAt(i); } prevStack.push(val); prevStack = stack; } return(result); }