Exemple #1
0
class Queue:
    def __init__(self):
        self._items = LinkedList()
    def __iter__(self):
        return iter(self._items)
    def __len__(self):
        return len(self._items)
    def __repr__(self):
        return repr(self._items)
    def enqueue(self, item_to_add):
        self._items.append(item_to_add)
    def dequeue(self):
        result = self.front()
        self._items.remove_first()
        return result
    def front(self):
        if len(self._items) == 0:
            raise QueueError('empty queue')
        return self._items[0]
Exemple #2
0
 def __init__(self):
     self._items = LinkedList()