本文整理匯總了Python中circular_buffer.CircularBuffer.overwrite方法的典型用法代碼示例。如果您正苦於以下問題:Python CircularBuffer.overwrite方法的具體用法?Python CircularBuffer.overwrite怎麽用?Python CircularBuffer.overwrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類circular_buffer.CircularBuffer
的用法示例。
在下文中一共展示了CircularBuffer.overwrite方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_overwrite_replaces_oldest_item
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import overwrite [as 別名]
def test_overwrite_replaces_oldest_item(self):
buf = CircularBuffer(2)
buf.write('1')
buf.write('2')
buf.overwrite('3')
self.assertEqual(buf.read(), '2')
self.assertEqual(buf.read(), '3')
示例2: test_overwrite_non_full_buffer
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import overwrite [as 別名]
def test_overwrite_non_full_buffer(self):
buf = CircularBuffer(2)
buf.overwrite('1')
buf.overwrite('2')
self.assertEqual('1', buf.read())
self.assertEqual('2', buf.read())
with self.assertRaises(BufferEmptyException):
buf.read()
示例3: test_overwrite_replaces_oldest_remaining_item
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import overwrite [as 別名]
def test_overwrite_replaces_oldest_remaining_item(self):
buf = CircularBuffer(3)
buf.write('1')
buf.write('2')
buf.write('3')
self.assertEqual(buf.read(), '1')
buf.write('4')
buf.overwrite('5')
self.assertEqual(buf.read(), '3')
self.assertEqual(buf.read(), '4')
self.assertEqual(buf.read(), '5')
示例4: test_alternate_read_and_overwrite
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import overwrite [as 別名]
def test_alternate_read_and_overwrite(self):
buf = CircularBuffer(5)
for c in '123':
buf.write(c)
buf.read()
buf.read()
buf.write('4')
buf.read()
for c in '5678':
buf.write(c)
buf.overwrite('A')
buf.overwrite('B')
self.assertEqual('6', buf.read())
self.assertEqual('7', buf.read())
self.assertEqual('8', buf.read())
self.assertEqual('A', buf.read())
self.assertEqual('B', buf.read())
with self.assertRaises(BufferEmptyException):
buf.read()
示例5: test_overwrite_non_full_buffer
# 需要導入模塊: from circular_buffer import CircularBuffer [as 別名]
# 或者: from circular_buffer.CircularBuffer import overwrite [as 別名]
def test_overwrite_non_full_buffer(self):
buf = CircularBuffer(2)
buf.write('1')
buf.overwrite('2')
self.assertEqual(buf.read(), '1')
self.assertEqual(buf.read(), '2')