mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-17 23:52:46 +01:00
Swapped implementation of MaxLengthQueue.
This commit is contained in:
parent
fe2f2c1ac0
commit
ff54eecefc
@ -234,28 +234,28 @@ class queue(object):
|
||||
self.back = []
|
||||
|
||||
|
||||
## class MaxLengthQueue(queue):
|
||||
## __slots__ = ('length',)
|
||||
## def __init__(self, length, seq=()):
|
||||
## self.length = length
|
||||
## queue.__init__(self, seq)
|
||||
class MaxLengthQueue(queue):
|
||||
__slots__ = ('length',)
|
||||
def __init__(self, length, seq=()):
|
||||
self.length = length
|
||||
queue.__init__(self, seq)
|
||||
|
||||
## def __getstate__(self):
|
||||
## return (self.length, queue.__getstate__(self))
|
||||
def __getstate__(self):
|
||||
return (self.length, queue.__getstate__(self))
|
||||
|
||||
## def __setstate__(self, (length, q)):
|
||||
## self.length = length
|
||||
## queue.__setstate__(self, q)
|
||||
def __setstate__(self, (length, q)):
|
||||
self.length = length
|
||||
queue.__setstate__(self, q)
|
||||
|
||||
## def enqueue(self, elt):
|
||||
## queue.enqueue(self, elt)
|
||||
## if len(self) > self.length:
|
||||
## self.dequeue()
|
||||
def enqueue(self, elt):
|
||||
queue.enqueue(self, elt)
|
||||
if len(self) > self.length:
|
||||
self.dequeue()
|
||||
|
||||
class MaxLengthQueue(RingBuffer):
|
||||
enqueue = RingBuffer.append
|
||||
def peek(self):
|
||||
return self[0]
|
||||
## class MaxLengthQueue(RingBuffer):
|
||||
## enqueue = RingBuffer.append
|
||||
## def peek(self):
|
||||
## return self[0]
|
||||
|
||||
|
||||
def sliceIndices(slice, length):
|
||||
|
Loading…
Reference in New Issue
Block a user