Skip to content

Commit

Permalink
Add CircBuffer::peek
Browse files Browse the repository at this point in the history
  • Loading branch information
danngreen committed Oct 2, 2024
1 parent 35981a4 commit 44bdc87
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions util/circular_buffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public:
return tail_;
}

T peek(size_t idx) const {
idx += tail_;
idx &= SIZE_MASK;
return buf_[idx];
}

private:
void inc_head() {
head_ = (head_ + 1) & SIZE_MASK;
Expand Down

0 comments on commit 44bdc87

Please sign in to comment.