mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
a/util: Add clear() method to HistoryBuffer
This commit is contained in:
parent
8729c0485e
commit
9651f66c4c
|
@ -178,6 +178,9 @@ public:
|
|||
const T &
|
||||
back() const;
|
||||
|
||||
void
|
||||
clear();
|
||||
|
||||
private:
|
||||
// Make sure all valid indices can be represented in a signed integer of the same size
|
||||
static_assert(MaxSize < (std::numeric_limits<size_t>::max() >> 1), "Cannot use most significant bit");
|
||||
|
@ -187,6 +190,14 @@ private:
|
|||
detail::RingBufferHelper helper_{MaxSize};
|
||||
};
|
||||
|
||||
|
||||
template <typename T, size_t MaxSize>
|
||||
void
|
||||
HistoryBuffer<T, MaxSize>::clear()
|
||||
{
|
||||
helper_.clear();
|
||||
}
|
||||
|
||||
template <typename T, size_t MaxSize>
|
||||
inline bool
|
||||
HistoryBuffer<T, MaxSize>::empty() const noexcept
|
||||
|
|
|
@ -113,6 +113,9 @@ public:
|
|||
size_t
|
||||
back_inner_index() const noexcept;
|
||||
|
||||
void
|
||||
clear();
|
||||
|
||||
private:
|
||||
// Would be const, but that would mess up our ability to copy/move containers using this.
|
||||
size_t capacity_;
|
||||
|
@ -135,6 +138,13 @@ private:
|
|||
};
|
||||
|
||||
|
||||
inline void
|
||||
RingBufferHelper::clear()
|
||||
{
|
||||
this->latest_inner_idx_ = 0;
|
||||
this->length_ = 0;
|
||||
}
|
||||
|
||||
inline size_t
|
||||
RingBufferHelper::front_impl_() const noexcept
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue