heapless icon indicating copy to clipboard operation
heapless copied to clipboard

HistoryBuffer Add pop_oldest

Open Ryder-C opened this issue 2 years ago • 1 comments

Motivation

There currently is no interface for removing elements from the HistoryBuffer.

Added

  • HistoryBuffer.pop_oldest()
  • HistoryBuffer.filled() getter to replace filled member variable
  • Unit test for HistoryBuffer.pop_oldest()

Changed

  • HistoryBuffer.len() to be a getter rather than computed on call.
  • HistoryBuffer.write()
  • HistoryBuffer.recent()
  • HistoryBuffer.oldest_ordered()
  • OldestOrdered.next()

Warning

HistoryBuffer.as_slice() no longer has the same meaning. The slice returned may contain unused values.

Ryder-C avatar Aug 31 '23 01:08 Ryder-C

what's the use case for this? It seems to me there's a lot of overlap with Deque here. IMO if you need push/pop you should use Deque, and HistoryBuffer should be used only when you want to do "statistics" on the last N values, not as a queue you pop things from.

Dirbaio avatar Oct 30 '23 23:10 Dirbaio