def test_pop(self): s = ArrayStack() s.push(1) self.assertEqual(s.pop(), 1) s.push(2) s.push(3) s.pop() self.assertEqual(s.top(), 2)
def three_stack(R: ArrayStack, S: ArrayStack, T: ArrayStack): R_len = len(R) while not S.is_empty(): R.push(S.pop()) while not T.is_empty(): R.push(T.pop()) while len(R) > R_len: S.push(R.pop())
def reverse_list(items): s = ArrayStack() for item in items: s.push(item) for i in range(len(items)): items[i] = s.pop()
def stack_clear(s: ArrayStack) -> None: if s.is_empty(): return s.pop() return stack_clear(s)
def transfer(S: ArrayStack, T: ArrayStack) -> None: while not S.is_empty(): T.push(S.pop())