smbanasik / SBLib

A library meant to serve as a competitor to the standard library.
MIT License
0 stars 0 forks source link

Implement Circular Queue #2

Open smbanasik opened 3 months ago

smbanasik commented 3 months ago

The circular queue would be a fixed size queue that, when the maximum count has been reached, would loop back and overwrite the first element.

smbanasik commented 3 days ago

We'll likely need to use two pointers (front and back), as well as having an element after the real end of the queue, which is a requirement for resolving the start == end issue, and enables this container to be used with iterators. I dislike the extra element, since the element's size scales with the size of the templated type, but without manually managing the memory of the area (void* implementation), I don't think much can be done about it. Since the usefulness of such a data type would be best with a stream of data (e.g. UDP, where data can be lost), and streaming large objects would be goofy, I think this compromise is fine.