2020-12-17 20:47:17 +01:00
|
|
|
class IntegerStack(list):
|
2020-11-18 21:20:04 +01:00
|
|
|
def __init__(self):
|
2020-12-17 20:47:17 +01:00
|
|
|
stack = [] * 128
|
|
|
|
self.extend(stack)
|
2020-12-02 21:18:58 +01:00
|
|
|
|
2020-11-18 21:20:04 +01:00
|
|
|
def depth(self):
|
2020-12-17 20:47:17 +01:00
|
|
|
return len(self)
|
2020-12-02 21:18:58 +01:00
|
|
|
|
2020-11-18 21:20:04 +01:00
|
|
|
def tos(self):
|
2020-12-17 20:47:17 +01:00
|
|
|
return self[-1]
|
2020-12-02 21:18:58 +01:00
|
|
|
|
2020-11-18 21:20:04 +01:00
|
|
|
def push(self, v):
|
2020-12-17 20:47:17 +01:00
|
|
|
self.append(v)
|
2020-12-02 21:18:58 +01:00
|
|
|
|
2020-11-18 21:20:04 +01:00
|
|
|
def dup(self):
|
2020-12-17 20:47:17 +01:00
|
|
|
self.append(self[-1])
|
2020-12-02 21:18:58 +01:00
|
|
|
|
2020-11-18 21:20:04 +01:00
|
|
|
def drop(self):
|
2020-12-17 20:47:17 +01:00
|
|
|
self.pop()
|
2020-12-02 21:18:58 +01:00
|
|
|
|
2020-11-18 21:20:04 +01:00
|
|
|
def swap(self):
|
2020-12-17 20:47:17 +01:00
|
|
|
a = self[-2]
|
|
|
|
self[-2] = self[-1]
|
|
|
|
self[-1] = a
|