util/CircularBuffer: add method GetSize()

This commit is contained in:
Max Kellermann
2014-03-15 23:11:13 +01:00
parent 3d4f588a7f
commit 89ac111853
2 changed files with 19 additions and 0 deletions

View File

@@ -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().