circular_queue< T > Class Template Reference |
Public Types | |
typedef const T * | const_pointer |
typedef const T & | const_reference |
typedef T * | pointer |
typedef T & | reference |
typedef std::size_t | size_type |
typedef T | value_type |
Public Member Functions | |
size_type | capacity () const ADOBE_NOTHROW |
circular_queue (std::size_t capacity=0) | |
void | clear () ADOBE_NOTHROW |
bool | empty () const ADOBE_NOTHROW |
reference | front () ADOBE_NOTHROW |
const_reference | front () const ADOBE_NOTHROW |
bool | full () const ADOBE_NOTHROW |
size_type | max_size () const ADOBE_NOTHROW |
void | pop_front () ADOBE_NOTHROW |
void | push_back (T x) |
void | putback () ADOBE_NOTHROW |
size_type | size () const ADOBE_NOTHROW |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const circular_queue &x, const circular_queue &y) |
bool | swap (circular_queue &x, circular_queue &y) |
Detailed Description
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 244 of file circular_queue.hpp.
Member Typedef Documentation
typedef const T* const_pointer |
Definition at line 249 of file circular_queue.hpp.
Const reference to T
.
Definition at line 251 of file circular_queue.hpp.
Pointer to T
.
Definition at line 248 of file circular_queue.hpp.
Reference to T
.
Definition at line 250 of file circular_queue.hpp.
Equivalent to std::size_t.
Definition at line 252 of file circular_queue.hpp.
The type of object, T
, stored in the queue.
Definition at line 247 of file circular_queue.hpp.
Constructor & Destructor Documentation
circular_queue | ( | std::size_t | capacity = 0 ) |
Creates a circular_queue.
- Parameters:
-
capacity Capacity for this queue.
Definition at line 320 of file circular_queue.hpp.
Member Function Documentation
adobe::circular_queue::size_type capacity | ( | ) | const |
- Returns:
Capacity
.
Definition at line 264 of file circular_queue.hpp.
void clear | ( | ) |
All elements are removed from the queue. Equivalent to while (size()) pop_front();
except with constant complexity.
Definition at line 269 of file circular_queue.hpp.
bool empty | ( | ) | const |
- Returns:
true
if the queue's size is 0.
Definition at line 266 of file circular_queue.hpp.
circular_queue< T >::const_reference front | ( | ) | const |
- Returns:
- A const reference to the element at the front of the queue, that is, the element least recently inserted.
- Precondition:
empty()
isfalse
.
Definition at line 363 of file circular_queue.hpp.
circular_queue< T >::reference front | ( | ) |
- Returns:
- A mutable reference to the element at the front of the queue, that is, the element least recently inserted.
- Precondition:
empty()
isfalse
.
Definition at line 354 of file circular_queue.hpp.
bool full | ( | ) | const |
- Returns:
true
ifsize() == capacity()
.
Definition at line 267 of file circular_queue.hpp.
adobe::circular_queue::size_type max_size | ( | ) | const |
Equivalent to capacity()
, provided for completeness.
- Returns:
Capacity
Definition at line 263 of file circular_queue.hpp.
void 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()
isfalse
.
- Postcondition:
size()
will be decremented by1
.
Definition at line 388 of file circular_queue.hpp.
void push_back | ( | T | x ) |
Definition at line 373 of file circular_queue.hpp.
void 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()
.
circular_queue<int> queue; queue.push_back(10); queue.push_back(20); assert(queue.front() == 10); queue.pop_front(); assert(queue.front() == 20); queue.putback(); assert(queue.front() == 10);
Definition at line 399 of file circular_queue.hpp.
circular_queue< T >::size_type size | ( | ) | const |
- Returns:
- The number of elements retained in the queue.
Definition at line 411 of file circular_queue.hpp.
Friends And Related Function Documentation
bool operator== | ( | const circular_queue< T > & | x, |
const circular_queue< T > & | y | ||
) | [related] |
- Parameters:
-
x first queue to compare y second queue to compare
- Complexity Guarantees:
- Linear.
size()
elements are compared (popped elements are not compared).
bool swap | ( | circular_queue< T > & | x, |
circular_queue< T > & | y | ||
) | [related] |
- 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 Guarantees:
- Linear.
size()
of larger queue elements are swapped.