mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Added a reset method to RingBuffer and queue.
This commit is contained in:
parent
ed92fcad2b
commit
b1e6cc53ac
@ -47,11 +47,14 @@ class RingBuffer(object):
|
|||||||
if maxSize <= 0:
|
if maxSize <= 0:
|
||||||
raise ValueError, 'maxSize must be > 0.'
|
raise ValueError, 'maxSize must be > 0.'
|
||||||
self.maxSize = maxSize
|
self.maxSize = maxSize
|
||||||
|
self.reset()
|
||||||
|
for elt in seq:
|
||||||
|
self.append(elt)
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
self.full = False
|
self.full = False
|
||||||
self.L = []
|
self.L = []
|
||||||
self.i = 0
|
self.i = 0
|
||||||
for elt in seq:
|
|
||||||
self.append(elt)
|
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.L)
|
return len(self.L)
|
||||||
@ -163,6 +166,10 @@ class queue(object):
|
|||||||
for elt in seq:
|
for elt in seq:
|
||||||
self.enqueue(elt)
|
self.enqueue(elt)
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self.back[:] = []
|
||||||
|
self.front[:] = []
|
||||||
|
|
||||||
def enqueue(self, elt):
|
def enqueue(self, elt):
|
||||||
self.back.append(elt)
|
self.back.append(elt)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user