# This implementation of the queue classes uses dictionaries
# instead of lists to store the collection of elements. Each element e
# that arrives is stored as timeStamp:e in the dictionary, where timeStamp
# is the "time" at which element e arrived. "time" starts of at 1 and
# is incremented (by 1) with the arrival of each new item. We keep track
# of the timeStamp of the earlier element still in the queue and the timeStamp
# of the most recent element in the queue. These two timeStamps help us quickly
# determine which element to dequeue and how to enqueue a new element.

class queueDict():

    def __init__(self):
        self.start = 0
        self.end  = 0
        self.D= {}

    def enqueue(self, item):
        self.end = self.end + 1
        self.D[self.end] = item

    def dequeue(self):
        self.start = self.start + 1
        item = self.D[self.start]
        del self.D[self.start]
        return item

    def __repr__(self):
        return str(self.D)
