stlab.adobe.com Adobe Systems Incorporated

#include <circular_queue.hpp>

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
capacityCapacity for this queue.

Definition at line 320 of file circular_queue.hpp.

Member Function Documentation

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 >::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 354 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() is false.

Definition at line 363 of file circular_queue.hpp.

bool full ( ) const
Returns
true if size() == capacity().

Definition at line 267 of file circular_queue.hpp.

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

Definition at line 388 of file circular_queue.hpp.

void push_back ( 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 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().
Postcondition
size() will be incremented by 1 and front() will return previous front.
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
xfirst queue to compare
ysecond 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
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 Guarantees:
Linear. size() of larger queue elements are swapped.

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google