A queue with a fixed capacity which supports putting back elements. Pushing more elements than there is capacity will pop the least recently pushed elements.
More...
#include <circular_queue.hpp>
template<typename T>
class adobe::circular_queue< T >
- Template Parameters
T
The queue's value type: the type of object that is stored in the queue.
- Model Of
-
- Type Requirements
T
is a model of Assignable.
Definition at line 250 of file circular_queue.hpp.
◆ value_type
◆ pointer
◆ const_pointer
◆ reference
◆ const_reference
◆ size_type
◆ circular_queue() [1/2]
◆ circular_queue() [2/2]
◆ operator=()
◆ size()
◆ max_size()
◆ capacity()
◆ empty()
◆ full()
◆ clear()
◆ front() [1/2]
- Returns
- A mutable reference to the element at the front of the queue, that is, the element least recently inserted.
- Precondition
empty()
is false.
Definition at line 361 of file circular_queue.hpp.
◆ front() [2/2]
- Returns
- A const reference to the element at the front of the queue, that is, the element least recently inserted.
- Precondition
empty()
is false.
Definition at line 369 of file circular_queue.hpp.
◆ push_back()
- Parameters
-
x | Inserts x at the back of the queue. |
- Postcondition
- If
full()
, the front item of the queue will be lost and the queue will remain full. Otherwise, size()
will be incremented by 1
.
Definition at line 377 of file circular_queue.hpp.
◆ pop_front()
The element at the front of the queue is removed. The element is not destructed and may be returned with putback()
.
- Precondition
empty()
is false.
- Postcondition
size()
will be decremented by 1
.
Definition at line 393 of file circular_queue.hpp.
◆ putback()
The last element popped from the front of the queue is returned to the front of the queue.
- Precondition
- Result undefined if putback() is called more times than pop_front().
-
Result is undefined if
full()
.
- Postcondition
size()
will be incremented by 1
and front()
will return previous front.
assert(queue.
front() == 10);
assert(queue.
front() == 20);
assert(queue.
front() == 10);
reference front() ADOBE_NOTHROW
circular_queue(std::size_t capacity=0)
void putback() ADOBE_NOTHROW
void pop_front() ADOBE_NOTHROW
Definition at line 403 of file circular_queue.hpp.
◆ swap [1/2]
◆ operator== [1/2]
◆ operator==() [2/2]
- Parameters
-
x | first queue to compare |
y | second queue to compare |
- Complexity Guarantee(s)
- Linear.
size()
elements are compared (popped elements are not compared).
◆ swap() [2/2]
- Parameters
-
x | first queue to swap |
y | second queue to swap |
- Exceptions
-
Unknown | If the elements are swappable without throwing then the circular_queue will be swappable without throwing. See the requirements for Assignable. |
- Complexity Guarantee(s)
- Linear.
size()
of larger queue elements are swapped.