26namespace xrt::auxiliary::util::detail {
126 size_t latest_inner_idx_ = 0;
139 front_impl_() const noexcept;
146 this->latest_inner_idx_ = 0;
151RingBufferHelper::front_impl_() const noexcept
155 return (latest_inner_idx_ + capacity_ - length_ + 1) % capacity_;
165 if (age >= length_) {
170 out_inner_idx = (latest_inner_idx_ + capacity_ - age) % capacity_;
190 if (index >= length_) {
194 out_inner_idx = (front_impl_() + index) % capacity_;
202 latest_inner_idx_ = (latest_inner_idx_ + 1) % capacity_;
205 length_ = std::min(length_ + 1, capacity_);
206 return latest_inner_idx_;
223 latest_inner_idx_ = (latest_inner_idx_ + capacity_ - 1) % capacity_;
233 return front_impl_();
242 return latest_inner_idx_;
All the bookkeeping for adapting a fixed-size array to a ring buffer.
Definition: u_template_historybuf_impl_helpers.hpp:46
constexpr RingBufferHelper(size_t capacity)
Construct for a given size.
Definition: u_template_historybuf_impl_helpers.hpp:49
size_t push_back_location() noexcept
Update internal state for pushing an element to the back, and return the inner index to store the ele...
Definition: u_template_historybuf_impl_helpers.hpp:199
bool pop_back() noexcept
Record the logical removal of the back element, if any.
Definition: u_template_historybuf_impl_helpers.hpp:217
bool empty() const noexcept
Is the buffer empty?
Definition: u_template_historybuf_impl_helpers.hpp:71
size_t front_inner_index() const noexcept
Get the inner index of the front (oldest) value, or capacity_ if empty.
Definition: u_template_historybuf_impl_helpers.hpp:228
size_t back_inner_index() const noexcept
Get the inner index of the back (newest) value, or capacity_ if empty.
Definition: u_template_historybuf_impl_helpers.hpp:237
void pop_front() noexcept
Record the logical removal of the front element, if any.
Definition: u_template_historybuf_impl_helpers.hpp:210
bool clamped_age_to_inner_index(size_t age, size_t &out_inner_idx) const noexcept
Get the inner index for a given age, clamping it if out of bounds.
Definition: u_template_historybuf_impl_helpers.hpp:175
size_t size() const noexcept
How many elements are in the buffer?
Definition: u_template_historybuf_impl_helpers.hpp:78
bool age_to_inner_index(size_t age, size_t &out_inner_idx) const noexcept
Get the inner index for a given age (if possible)
Definition: u_template_historybuf_impl_helpers.hpp:159
bool index_to_inner_index(size_t index, size_t &out_inner_idx) const noexcept
Get the inner index for a given index (if possible)
Definition: u_template_historybuf_impl_helpers.hpp:184