Ejemplo n.º 1
0
class Queue:
    def __init__(self, type: str):
        if type == "array":
            self.my_queue = ArrayDeque()
        elif type == "linked":
            self.my_queue = LinkedList()

    def add(self, val):
        self.my_queue.push_back(val)

    def remove(self):
        if self.my_queue.is_empty():
            return None
        else:
            return self.the_queue.pop_front()
    
    def get_size(self):
        return self.my_queue.get_size()
Ejemplo n.º 2
0
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()