mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Added reset() to smallqueue.
This commit is contained in:
parent
b0f5674f91
commit
ae61e178ec
@ -294,6 +294,12 @@ class smallqueue(list):
|
|||||||
def peek(self):
|
def peek(self):
|
||||||
return self[0]
|
return self[0]
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return 'smallqueue([%s])' % ', '.join(map(repr, self))
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
self[:] = []
|
||||||
|
|
||||||
|
|
||||||
class MaxLengthQueue(queue):
|
class MaxLengthQueue(queue):
|
||||||
__slots__ = ('length',)
|
__slots__ = ('length',)
|
||||||
|
@ -199,6 +199,13 @@ class RingBufferTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class QueueTest(unittest.TestCase):
|
class QueueTest(unittest.TestCase):
|
||||||
|
def testReset(self):
|
||||||
|
q = queue()
|
||||||
|
q.enqueue(1)
|
||||||
|
self.assertEqual(len(q), 1)
|
||||||
|
q.reset()
|
||||||
|
self.assertEqual(len(q), 0)
|
||||||
|
|
||||||
def testGetitem(self):
|
def testGetitem(self):
|
||||||
q = queue()
|
q = queue()
|
||||||
n = 10
|
n = 10
|
||||||
@ -357,6 +364,13 @@ class QueueTest(unittest.TestCase):
|
|||||||
queue = smallqueue
|
queue = smallqueue
|
||||||
|
|
||||||
class SmallQueueTest(unittest.TestCase):
|
class SmallQueueTest(unittest.TestCase):
|
||||||
|
def testReset(self):
|
||||||
|
q = queue()
|
||||||
|
q.enqueue(1)
|
||||||
|
self.assertEqual(len(q), 1)
|
||||||
|
q.reset()
|
||||||
|
self.assertEqual(len(q), 0)
|
||||||
|
|
||||||
def testGetitem(self):
|
def testGetitem(self):
|
||||||
q = queue()
|
q = queue()
|
||||||
n = 10
|
n = 10
|
||||||
|
Loading…
Reference in New Issue
Block a user