mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-08 19:22:33 +01:00
utils.structures: Prevent a RingBuffer from being bigger than the new size, when calling resize().
This commit is contained in:
parent
6b7db2e9f1
commit
cab1830140
@ -52,12 +52,15 @@ class RingBuffer(object):
|
||||
self.L = []
|
||||
self.i = 0
|
||||
|
||||
def resize(self, i):
|
||||
if self.full:
|
||||
L = list(self)
|
||||
self.reset()
|
||||
self.L = L
|
||||
self.maxSize = i
|
||||
def resize(self, size):
|
||||
L = list(self)
|
||||
i = self.i
|
||||
self.reset()
|
||||
self.maxSize = size
|
||||
for elt in L[i+1:]:
|
||||
self.append(elt)
|
||||
for elt in L[0:i]:
|
||||
self.append(elt)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.L)
|
||||
|
Loading…
Reference in New Issue
Block a user