Ejemplo n.º 1
0
class Queue:
    def __init__(self):
        self.items = UnorderedList()

    def enqueue(self, item):
        self.items.add(item)

    def dequeue(self):
        return self.items.pop()

    def isEmpty(self):
        return self.items.isEmpty()

    def size(self):
        return self.items.length()
Ejemplo n.º 2
0
class Deque:
    def __init__(self):
        self.items = UnorderedList()

    def __str__(self):
        return self.items.__str__()

    def addFront(self, item):
        self.items.add(item)

    def addRear(self, item):
        self.items.append(item)

    def removeFront(self):
        return self.items.popPos(0)

    def removeRear(self):
        return self.items.pop()

    def isEmpty(self):
        return self.items.isEmpty()

    def size(self):
        return self.items.length()