util/CircularBuffer: add method GetSize()
This commit is contained in:
@@ -98,6 +98,15 @@ public:
|
||||
return Next(tail) == head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of elements stored in this buffer.
|
||||
*/
|
||||
constexpr size_type GetSize() const {
|
||||
return head <= tail
|
||||
? tail - head
|
||||
: capacity - head + tail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares writing. Returns a buffer range which may be written.
|
||||
* When you are finished, call Append().
|
||||
|
Reference in New Issue
Block a user