class Stack: def __init__(self, type="array"): if type == "array": self.__array = ArrayDeque() else: self.__array = LinkedList() def push(self, value): self.__array.push_front(value) def pop(self): return self.__array.pop_front() def get_size(self): return self.__array.get_size()
class Stack: def __init__(self, type: str): if type == 'array': self.container = ArrayDeque() else: self.container = LinkedList() def push(self, element): self.container.push_front(element) def pop(self): return self.container.pop_front() def get_size(self): return self.container.get_size()
class Stack: def __init__(self, datastructure = "array"): if datastructure == "array": self.datastructure = ArrayDeque() else: self.datastructure = LinkedList() def push(self, value): self.datastructure.push_front(value) def pop(self): return self.datastructure.pop_front() def get_size(self): return self.datastructure.get_size()
class Stack: def __init__(self, type: str): if type == "array": self.PEZ = ArrayDeque() elif type == "linked": self.PEZ = LinkedList() def push(self, val): self.PEZ.push_front(val) def pop(self): if self.PEZ.is_empty(): return None else: return self.PEZ.pop_front() def get_size(self): return self.PEZ.get_size()
class Stack(): def __init__(self, a_type): if a_type == 'array': self.instance = ArrayDeque() else: self.instance = LinkedList() def push(self, value): return self.instance.push_front(value) def pop(self): return self.instance.pop_front() def get_size(self): return self.instance.get_size()
print(deque) print("\nTESTING LINKED_LIST\n") lis = LinkedList() lis.push_back(3) lis.push_back(1) lis.push_back(6) lis.push_back(9) print("container of size: " + str(lis.get_size()) + ":") print(lis) print(lis.pop_front()) print(lis.pop_front()) print("container of size: " + str(lis.get_size()) + ":") print(lis) lis.push_front(11) lis.push_front(16) lis.push_front(13) print("container of size: " + str(lis.get_size()) + ":") print(lis) print(lis.pop_front()) print(lis.pop_front()) print(lis.pop_front()) print(lis.pop_front()) print("container of size: " + str(lis.get_size()) + ":") print(lis) print(lis.pop_front()) print(lis.pop_front()) print("container of size: " + str(lis.get_size()) + ":") print(lis)