cpython/Lib/compiler/misc.py

25 lines
536 B
Python
Raw Normal View History

class Set:
def __init__(self):
self.elts = {}
2000-02-10 20:54:27 +00:00
def __len__(self):
return len(self.elts)
def add(self, elt):
self.elts[elt] = elt
def items(self):
return self.elts.keys()
def has_elt(self, elt):
return self.elts.has_key(elt)
2000-02-10 00:43:22 +00:00
def remove(self, elt):
del self.elts[elt]
class Stack:
def __init__(self):
self.stack = []
self.pop = self.stack.pop
2000-02-10 20:54:27 +00:00
def __len__(self):
return len(self.stack)
def push(self, elt):
self.stack.append(elt)
def top(self):
return self.stack[-1]