Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches

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>

Inheritance diagram for circular_queue< T >:

Public Types

typedef T value_type
typedef T * pointer
typedef const T * const_pointer
typedef T & reference
typedef const T & const_reference
typedef std::size_t size_type

Public Member Functions

 circular_queue (std::size_t capacity=0)
 circular_queue (const circular_queue &rhs)
circular_queueoperator= (circular_queue rhs)
size_type size () const ADOBE_NOTHROW
size_type max_size () const ADOBE_NOTHROW
size_type capacity () const ADOBE_NOTHROW
bool empty () const ADOBE_NOTHROW
bool full () const ADOBE_NOTHROW
void clear () ADOBE_NOTHROW
reference front () ADOBE_NOTHROW
const_reference front () const ADOBE_NOTHROW
void push_back (T x)
void pop_front () ADOBE_NOTHROW
void putback () ADOBE_NOTHROW

Friends

void swap (circular_queue &x, circular_queue &y)
bool operator== (const circular_queue &x, const circular_queue &y)

(Note that these are not member symbols.)

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 250 of file circular_queue.hpp.

Member Typedef Documentation

◆ value_type

template<typename T>
typedef T value_type

The type of object, T, stored in the queue.

Definition at line 252 of file circular_queue.hpp.

◆ pointer

template<typename T>
typedef T* pointer

Pointer to T.

Definition at line 253 of file circular_queue.hpp.

◆ const_pointer

template<typename T>
typedef const T* const_pointer

Definition at line 254 of file circular_queue.hpp.

◆ reference

template<typename T>
typedef T& reference

Reference to T.

Definition at line 255 of file circular_queue.hpp.

◆ const_reference

template<typename T>
typedef const T& const_reference

Const reference to T.

Definition at line 256 of file circular_queue.hpp.

◆ size_type

template<typename T>
typedef std::size_t size_type

Equivalent to std::size_t.

Definition at line 257 of file circular_queue.hpp.

Constructor & Destructor Documentation

◆ circular_queue() [1/2]

template<typename T>
circular_queue ( std::size_t capacity = 0)

Creates a circular_queue.

Parameters
capacityCapacity for this queue.

Definition at line 330 of file circular_queue.hpp.

◆ circular_queue() [2/2]

template<typename T>
circular_queue ( const circular_queue< T > & rhs)

Definition at line 339 of file circular_queue.hpp.

Member Function Documentation

◆ operator=()

template<typename T>
circular_queue< T > & operator= ( circular_queue< T > rhs)

Definition at line 352 of file circular_queue.hpp.

◆ size()

template<typename T>
circular_queue< T >::size_type size ( ) const
Returns
The number of elements retained in the queue.

Definition at line 414 of file circular_queue.hpp.

◆ max_size()

template<typename T>
size_type max_size ( ) const

Equivalent to capacity(), provided for completeness.

Returns
Capacity

Definition at line 268 of file circular_queue.hpp.

◆ capacity()

template<typename T>
size_type capacity ( ) const
Returns
Capacity.

Definition at line 269 of file circular_queue.hpp.

◆ empty()

template<typename T>
bool empty ( ) const
Returns
true if the queue's size is 0.

Definition at line 271 of file circular_queue.hpp.

◆ full()

template<typename T>
bool full ( ) const
Returns
true if size() == capacity().

Definition at line 272 of file circular_queue.hpp.

◆ clear()

template<typename T>
void clear ( )

All elements are removed from the queue. Equivalent to while (size()) pop_front(); except with constant complexity.

Definition at line 274 of file circular_queue.hpp.

◆ front() [1/2]

template<typename T>
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() is false.

Definition at line 361 of file circular_queue.hpp.

◆ front() [2/2]

template<typename T>
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() is false.

Definition at line 369 of file circular_queue.hpp.

◆ push_back()

template<typename T>
void push_back ( T x)
Parameters
xInserts 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()

template<typename T>
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() is false.
Postcondition
size() will be decremented by 1.

Definition at line 393 of file circular_queue.hpp.

◆ putback()

template<typename T>
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().
Postcondition
size() will be incremented by 1 and front() will return previous front.
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);
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]

template<typename T>
void swap ( circular_queue< T > & x,
circular_queue< T > & y )
friend

Definition at line 290 of file circular_queue.hpp.

◆ operator== [1/2]

template<typename T>
bool operator== ( const circular_queue< T > & x,
const circular_queue< T > & y )
friend

◆ operator==() [2/2]

template<typename T>
bool operator== ( const circular_queue< T > & x,
const circular_queue< T > & y )
related
Parameters
xfirst queue to compare
ysecond queue to compare
Complexity Guarantee(s)
Linear. size() elements are compared (popped elements are not compared).

◆ swap() [2/2]

template<typename T>
bool swap ( circular_queue< T > & x,
circular_queue< T > & y )
related
Parameters
xfirst queue to swap
ysecond queue to swap
Exceptions
UnknownIf 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.