Skip to content
Snippets Groups Projects
Commit 6ac6a464 authored by Luca Erbetta's avatar Luca Erbetta :rocket:
Browse files

[CircularBuffer] Comments

parent fc9c7a24
Branches
Tags
No related merge requests found
...@@ -62,12 +62,15 @@ public: ...@@ -62,12 +62,15 @@ public:
/** /**
* Gets an element from the buffer, without removing it * Gets an element from the buffer, without removing it
* Index starts at the element returned by get() or pop(): get(0) is * Index starts from the oldest element in the buffer: get(0) returns the
* the same as get() * same element as get()
* *
* @warning Remember to catch the exception! * @warning Remember to catch the exception!
* @throw range_error if index >= count()
*
* @param i Index of the elemnt to get, starting from the oldest
*
* @return the element * @return the element
* @throws range_error if buffer is empty
*/ */
virtual T& get(unsigned int i) virtual T& get(unsigned int i)
{ {
...@@ -81,21 +84,19 @@ public: ...@@ -81,21 +84,19 @@ public:
} }
/** /**
* @brief Returns the last element added in the buffer * @brief Returns the last element added in the buffer.
*
* @throw range_error if buffer is empty
* @warning Remember to catch the exception! * @warning Remember to catch the exception!
* @return the element * @return the element
* @throws range_error if buffer is empty
*/ */
virtual T& last() virtual T& last() { return get(count() - 1); }
{
return get(count() - 1);
}
/** /**
* Gets the first element from the buffer, without removing it * Gets the first element from the buffer, without removing it
* @throw range_error if buffer is empty
* @warning Remember to catch the exception! * @warning Remember to catch the exception!
* @return the element * @return the element
* @throws range_error if buffer is empty
*/ */
virtual T& get() virtual T& get()
{ {
...@@ -109,9 +110,9 @@ public: ...@@ -109,9 +110,9 @@ public:
/** /**
* Pops the first element in the buffer. * Pops the first element in the buffer.
* @throw range_error if buffer is empty
* @warning Remember to catch the exception! * @warning Remember to catch the exception!
* @return the element that has been popped * @return the element that has been popped
* @throws range_error if buffer is empty
*/ */
virtual const T& pop() virtual const T& pop()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment