Swapped implementation of MaxLengthQueue.

This commit is contained in:
Jeremy Fincher 2003-04-22 11:16:03 +00:00
parent fe2f2c1ac0
commit ff54eecefc

View File

@ -234,28 +234,28 @@ class queue(object):
self.back = [] self.back = []
## class MaxLengthQueue(queue): class MaxLengthQueue(queue):
## __slots__ = ('length',) __slots__ = ('length',)
## def __init__(self, length, seq=()): def __init__(self, length, seq=()):
## self.length = length self.length = length
## queue.__init__(self, seq) queue.__init__(self, seq)
## def __getstate__(self): def __getstate__(self):
## return (self.length, queue.__getstate__(self)) return (self.length, queue.__getstate__(self))
## def __setstate__(self, (length, q)): def __setstate__(self, (length, q)):
## self.length = length self.length = length
## queue.__setstate__(self, q) queue.__setstate__(self, q)
## def enqueue(self, elt): def enqueue(self, elt):
## queue.enqueue(self, elt) queue.enqueue(self, elt)
## if len(self) > self.length: if len(self) > self.length:
## self.dequeue() self.dequeue()
class MaxLengthQueue(RingBuffer): ## class MaxLengthQueue(RingBuffer):
enqueue = RingBuffer.append ## enqueue = RingBuffer.append
def peek(self): ## def peek(self):
return self[0] ## return self[0]
def sliceIndices(slice, length): def sliceIndices(slice, length):