diff options
author | Max Kellermann <max@duempel.org> | 2014-03-15 23:11:13 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-03-16 00:27:18 +0100 |
commit | 89ac111853eb4bae2fc358087c4c4657939321c0 (patch) | |
tree | 735bd12a1896ff049d58d1138eaa1ec99457561d /src | |
parent | 3d4f588a7ff6b3c0953d706c526f4f391db9dfd2 (diff) | |
download | mpd-89ac111853eb4bae2fc358087c4c4657939321c0.tar.gz mpd-89ac111853eb4bae2fc358087c4c4657939321c0.tar.xz mpd-89ac111853eb4bae2fc358087c4c4657939321c0.zip |
util/CircularBuffer: add method GetSize()
Diffstat (limited to '')
-rw-r--r-- | src/util/CircularBuffer.hxx | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/util/CircularBuffer.hxx b/src/util/CircularBuffer.hxx index 67b60e198..0321b91f6 100644 --- a/src/util/CircularBuffer.hxx +++ b/src/util/CircularBuffer.hxx @@ -99,6 +99,15 @@ public: } /** + * 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(). */ |