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 Queue: def __init__(self, datastructure="array"): if datastructure == "array": self.datastructure = ArrayDeque() else: self.datastructure = LinkedList() def add(self, value): self.datastructure.push_back(value) def remove(self): return self.datastructure.pop_front() def get_size(self): return self.datastructure.get_size()
class Queue: def __init__(self, type="array"): if type == "array": self.__array = ArrayDeque() else: self.__array = LinkedList() def add(self, value): self.__array.push_back(value) def remove(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 Queue: def __init__(self, type: str): if type == 'array': self.container = ArrayDeque() else: self.container = LinkedList() def add(self, element): self.container.push_back(element) def remove(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 Queue: def __init__(self, _type_): self.type = _type_ if self.type == 'array': self.queue = ArrayDeque() elif self.type == 'linked': self.queue = LinkedList() def add(self, value): self.queue.push_back(value) def remove(self): return self.queue.pop_front() def get_size(self): return self.queue.get_size()
class Queue: def __init__(self, a_type): if a_type == 'array': self.instance = ArrayDeque() else: self.instance = LinkedList() def add(self, value): return self.instance.push_back(value) def remove(self): return self.instance.pop_front() def get_size(self): return self.instance.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()
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 Queue: def __init__(self): # Pick one of these to use. # Stack must have the container you dont choose for Queue self.container = LinkedList() #self.container = ArrayDeque() def add(self, data): self.container.push_back(data) def remove(self): return self.container.pop_front() def get_size(self): return self.container.get_size() def __str__(self): return str(self.container)
print(deque.pop_back()) print(deque.pop_front()) print(deque.pop_back()) print("container of size: " + str(deque.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())