Home Libraries People FAQ More

Main Page | Class Hierarchy | Class List | File List | Class Members

boost::circular_buffer< T, Alloc > Class Template Reference

Circular buffer - a STL compliant container. More...

#include <base.hpp>

Inherits cb_iterator_registry.

Inherited by boost::circular_buffer_space_optimized< T, Alloc > [private].

List of all members.

Public Types

typedef Alloc::value_type value_type
 The type of the elements stored in the circular buffer.

typedef Alloc::pointer pointer
 Pointer to the element.

typedef Alloc::const_pointer const_pointer
 Const pointer to the element.

typedef Alloc::reference reference
 Reference to the element.

typedef Alloc::const_reference const_reference
 Const reference to the element.

typedef Alloc::difference_type difference_type
 Distance type.

typedef Alloc::size_type size_type
 Size type.

typedef Alloc allocator_type
 The type of the allocator used in the circular buffer.

typedef cb_details::cb_iterator<
circular_buffer< T, Alloc >,
cb_details::cb_const_traits<
Alloc > > 
const_iterator
 Const (random access) iterator used to iterate through a circular buffer.

typedef cb_details::cb_iterator<
circular_buffer< T, Alloc >,
cb_details::cb_nonconst_traits<
Alloc > > 
iterator
 Iterator (random access) used to iterate through a circular buffer.

typedef reverse_iterator<
const_iterator
const_reverse_iterator
 Const iterator used to iterate backwards through a circular buffer.

typedef reverse_iterator<
iterator
reverse_iterator
 Iterator used to iterate backwards through a circular buffer.


Public Member Functions

allocator_type get_allocator () const
 Return the allocator.

allocator_typeget_allocator ()
 Return the allocator.

iterator begin ()
 Return an iterator pointing to the beginning of the circular buffer.

iterator end ()
 Return an iterator pointing to the end of the circular buffer.

const_iterator begin () const
 Return a const iterator pointing to the beginning of the circular buffer.

const_iterator end () const
 Return a const iterator pointing to the end of the circular buffer.

reverse_iterator rbegin ()
 Return a reverse iterator pointing to the beginning of the reversed circular buffer.

reverse_iterator rend ()
 Return a reverse iterator pointing to the end of the reversed circular buffer.

const_reverse_iterator rbegin () const
 Return a const reverse iterator pointing to the beginning of the reversed circular buffer.

const_reverse_iterator rend () const
 Return a const reverse iterator pointing to the end of the reversed circular buffer.

reference operator[] (size_type index)
 Return the element at the index position.

return_value_type operator[] (size_type index) const
 Return the element at the index position.

reference at (size_type index)
 Return the element at the index position.

return_value_type at (size_type index) const
 Return the element at the index position.

reference front ()
 Return the first (leftmost) element.

reference back ()
 Return the last (rightmost) element.

return_value_type front () const
 Return the first (leftmost) element.

return_value_type back () const
 Return the last (rightmost) element.

pointer data ()
 Return pointer to data stored in the circular buffer as a continuous array of values.

size_type size () const
 Return the number of elements currently stored in the circular buffer.

size_type max_size () const
 Return the largest possible size (or capacity) of the circular buffer.

bool empty () const
 Is the circular buffer empty?

bool full () const
 Is the circular buffer full?

size_type capacity () const
 Return the capacity of the circular buffer.

void set_capacity (size_type new_capacity, bool remove_front=true)
 Change the capacity of the circular buffer.

void resize (size_type new_size, param_value_type item=T(), bool remove_front=true)
 Change the size of the circular buffer.

 circular_buffer (size_type capacity, const allocator_type &alloc=allocator_type())
 Create an empty circular buffer with a given capacity.

 circular_buffer (size_type capacity, param_value_type item, const allocator_type &alloc=allocator_type())
 Create a full circular buffer with a given capacity and filled with copies of item.

 circular_buffer (const circular_buffer< T, Alloc > &cb)
 Copy constructor.

template<class InputIterator>  circular_buffer (size_type capacity, InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
 Create a circular buffer with a copy of a range.

 ~circular_buffer ()
 Destructor.

circular_buffer< T, Alloc > & operator= (const circular_buffer< T, Alloc > &cb)
 Assignment operator.

void assign (size_type n, param_value_type item)
 Assign n items into the circular buffer.

template<class InputIterator> void assign (InputIterator first, InputIterator last)
 Assign a copy of range.

void swap (circular_buffer &cb)
 Swap the contents of two circular buffers.

void push_back (param_value_type item)
 Insert a new element at the end.

void push_back ()
 Insert a new element with the default value at the end.

void push_front (param_value_type item)
 Insert a new element at the start.

void push_front ()
 Insert a new element with the default value at the start.

void pop_back ()
 Remove the last (rightmost) element.

void pop_front ()
 Remove the first (leftmost) element.

iterator insert (iterator pos, param_value_type item)
 Insert the item before the given position.

iterator insert (iterator pos)
 Insert a new element with the default value before the given position.

void insert (iterator pos, size_type n, param_value_type item)
 Insert n copies of the item before the given position.

template<class InputIterator> void insert (iterator pos, InputIterator first, InputIterator last)
 Insert the range [first, last) before the given position.

iterator rinsert (iterator pos, param_value_type item)
 Insert an item before the given position.

iterator rinsert (iterator pos)
 Insert a new element with the default value before the given position.

void rinsert (iterator pos, size_type n, param_value_type item)
 Insert n copies of the item before the given position.

template<class InputIterator> void rinsert (iterator pos, InputIterator first, InputIterator last)
 Insert the range [first, last) before the given position.

iterator erase (iterator pos)
 Erase the element at the given position.

iterator erase (iterator first, iterator last)
 Erase the range [first, last).

void clear ()
 Erase all the stored elements.


Detailed Description

template<class T, class Alloc>
class boost::circular_buffer< T, Alloc >

Circular buffer - a STL compliant container.

Parameters:
T The type of the elements stored in the circular buffer.
Alloc The allocator type used for all internal memory management.
Author:
Jan Gaspar
Version:
3.6
Date:
2004
For more information how to use the circular buffer see the documentation.


Member Typedef Documentation

template<class T, class Alloc>
typedef Alloc boost::circular_buffer< T, Alloc >::allocator_type
 

The type of the allocator used in the circular buffer.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef cb_details::cb_iterator< circular_buffer<T, Alloc>, cb_details::cb_const_traits<Alloc> > boost::circular_buffer< T, Alloc >::const_iterator
 

Const (random access) iterator used to iterate through a circular buffer.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef Alloc::const_pointer boost::circular_buffer< T, Alloc >::const_pointer
 

Const pointer to the element.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef Alloc::const_reference boost::circular_buffer< T, Alloc >::const_reference
 

Const reference to the element.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef reverse_iterator<const_iterator> boost::circular_buffer< T, Alloc >::const_reverse_iterator
 

Const iterator used to iterate backwards through a circular buffer.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef Alloc::difference_type boost::circular_buffer< T, Alloc >::difference_type
 

Distance type.

A signed integral type used to represent the distance between two iterators.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef cb_details::cb_iterator< circular_buffer<T, Alloc>, cb_details::cb_nonconst_traits<Alloc> > boost::circular_buffer< T, Alloc >::iterator
 

Iterator (random access) used to iterate through a circular buffer.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef Alloc::pointer boost::circular_buffer< T, Alloc >::pointer
 

Pointer to the element.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef Alloc::reference boost::circular_buffer< T, Alloc >::reference
 

Reference to the element.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef reverse_iterator<iterator> boost::circular_buffer< T, Alloc >::reverse_iterator
 

Iterator used to iterate backwards through a circular buffer.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef Alloc::size_type boost::circular_buffer< T, Alloc >::size_type
 

Size type.

An unsigned integral type that can represent any nonnegative value of the container's distance type.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
typedef Alloc::value_type boost::circular_buffer< T, Alloc >::value_type
 

The type of the elements stored in the circular buffer.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.


Constructor & Destructor Documentation

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::circular_buffer size_type  capacity,
const allocator_type alloc = allocator_type()
[inline, explicit]
 

Create an empty circular buffer with a given capacity.

Postcondition:
(*this).capacity() == capacity && (*this).size == 0
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::circular_buffer size_type  capacity,
param_value_type  item,
const allocator_type alloc = allocator_type()
[inline]
 

Create a full circular buffer with a given capacity and filled with copies of item.

Postcondition:
(*this).size() == capacity && (*this)[0] == (*this)[1] == ... == (*this).back() == item
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).
Whatever T::T(const T&) throws.

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::circular_buffer const circular_buffer< T, Alloc > &  cb  )  [inline]
 

Copy constructor.

Postcondition:
*this == cb
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).
Whatever T::T(const T&) throws.

template<class T, class Alloc>
template<class InputIterator>
boost::circular_buffer< T, Alloc >::circular_buffer size_type  capacity,
InputIterator  first,
InputIterator  last,
const allocator_type alloc = allocator_type()
[inline]
 

Create a circular buffer with a copy of a range.

Precondition:
Valid range [first, last).
Postcondition:
(*this).capacity() == capacity
If the number of items to copy from the range [first, last) is greater than the specified capacity then only elements from the range [last - capacity, last) will be copied.
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).
Whatever T::T(const T&) throws.

template<class T, class Alloc>
boost::circular_buffer< T, Alloc >::~circular_buffer  )  [inline]
 

Destructor.


Member Function Documentation

template<class T, class Alloc>
template<class InputIterator>
void boost::circular_buffer< T, Alloc >::assign InputIterator  first,
InputIterator  last
[inline]
 

Assign a copy of range.

Precondition:
Valid range [first, last).
Postcondition:
(*this).size() == std::distance(first, last)
If the number of items to be assigned exceeds the capacity of the circular buffer the capacity is set to that number otherwise is stays unchanged.
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::assign size_type  n,
param_value_type  item
[inline]
 

Assign n items into the circular buffer.

Postcondition:
(*this).size() == n && (*this)[0] == (*this)[1] == ... == (*this).back() == item
If the number of items to be assigned exceeds the capacity of the circular buffer the capacity is increased to n otherwise it stays unchanged.
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
return_value_type boost::circular_buffer< T, Alloc >::at size_type  index  )  const [inline]
 

Return the element at the index position.

Exceptions:
std::out_of_range thrown when the index is invalid.

template<class T, class Alloc>
reference boost::circular_buffer< T, Alloc >::at size_type  index  )  [inline]
 

Return the element at the index position.

Exceptions:
std::out_of_range thrown when the index is invalid.

template<class T, class Alloc>
return_value_type boost::circular_buffer< T, Alloc >::back  )  const [inline]
 

Return the last (rightmost) element.

Precondition:
!*(this).empty()

template<class T, class Alloc>
reference boost::circular_buffer< T, Alloc >::back  )  [inline]
 

Return the last (rightmost) element.

Precondition:
!*(this).empty()

template<class T, class Alloc>
const_iterator boost::circular_buffer< T, Alloc >::begin  )  const [inline]
 

Return a const iterator pointing to the beginning of the circular buffer.

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::begin  )  [inline]
 

Return an iterator pointing to the beginning of the circular buffer.

template<class T, class Alloc>
size_type boost::circular_buffer< T, Alloc >::capacity  )  const [inline]
 

Return the capacity of the circular buffer.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::clear  )  [inline]
 

Erase all the stored elements.

Postcondition:
(*this).size() == 0
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
pointer boost::circular_buffer< T, Alloc >::data  )  [inline]
 

Return pointer to data stored in the circular buffer as a continuous array of values.

This method can be useful e.g. when passing the stored data into the legacy C API.

Postcondition:
&(*this)[0] < &(*this)[1] < ... < &(*this).back()
Returns:
0 if empty.
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

template<class T, class Alloc>
bool boost::circular_buffer< T, Alloc >::empty  )  const [inline]
 

Is the circular buffer empty?

Returns:
true if there are no elements stored in the circular buffer.

false otherwise.

template<class T, class Alloc>
const_iterator boost::circular_buffer< T, Alloc >::end  )  const [inline]
 

Return a const iterator pointing to the end of the circular buffer.

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::end  )  [inline]
 

Return an iterator pointing to the end of the circular buffer.

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::erase iterator  first,
iterator  last
[inline]
 

Erase the range [first, last).

Precondition:
Valid range [first, last).

size_type old_size = (*this).size()

Postcondition:
(*this).size() == old_size - std::distance(first, last)
Removes the elements from the range [first, last).
Returns:
iterator to the first element remaining beyond the removed element or (*this).end() if no such element exists.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::erase iterator  pos  )  [inline]
 

Erase the element at the given position.

Precondition:
Valid pos iterator.

size_type old_size = (*this).size()

Postcondition:
(*this).size() == old_size - 1
Removes an element at the position pos.
Returns:
iterator to the first element remaining beyond the removed element or (*this).end() if no such element exists.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
return_value_type boost::circular_buffer< T, Alloc >::front  )  const [inline]
 

Return the first (leftmost) element.

Precondition:
!*(this).empty()

template<class T, class Alloc>
reference boost::circular_buffer< T, Alloc >::front  )  [inline]
 

Return the first (leftmost) element.

Precondition:
!*(this).empty()

template<class T, class Alloc>
bool boost::circular_buffer< T, Alloc >::full  )  const [inline]
 

Is the circular buffer full?

Returns:
true if the number of elements stored in the circular buffer equals the capacity of the circular buffer.

false otherwise.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
allocator_type& boost::circular_buffer< T, Alloc >::get_allocator  )  [inline]
 

Return the allocator.

Note:
This method was added in order to optimize obtaining of the allocator with a state, although use of stateful allocators in STL is discouraged.

template<class T, class Alloc>
allocator_type boost::circular_buffer< T, Alloc >::get_allocator  )  const [inline]
 

Return the allocator.

template<class T, class Alloc>
template<class InputIterator>
void boost::circular_buffer< T, Alloc >::insert iterator  pos,
InputIterator  first,
InputIterator  last
[inline]
 

Insert the range [first, last) before the given position.

Precondition:
Valid pos iterator and valid range [first, last).
Postcondition:
This operation preserves the capacity of the circular buffer. If the insertion would result in exceeding the capacity of the circular buffer then the necessary number of elements from the beginning (left) of the circular buffer will be removed or not the whole range will be inserted or both. In case the whole range cannot be inserted it will be inserted just some elements from the end (right) of the range (see the example).
Example:
array to insert: int array[] = { 5, 6, 7, 8, 9 };
original circular buffer |1|2|3|4| | | - capacity: 6, size: 4
position ---------------------^
insert(position, array, array + 5);
(If the operation won't preserve capacity, the buffer would look like this |1|2|5|6|7|8|9|3|4|)
RESULTING circular buffer |6|7|8|9|3|4| - capacity: 6, size: 6
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::insert iterator  pos,
size_type  n,
param_value_type  item
[inline]
 

Insert n copies of the item before the given position.

Precondition:
Valid pos iterator.
Postcondition:
This operation preserves the capacity of the circular buffer. If the insertion would result in exceeding the capacity of the circular buffer then the necessary number of elements from the beginning (left) of the circular buffer will be removed or not all n elements will be inserted or both.
Example:
original circular buffer |1|2|3|4| | | - capacity: 6, size: 4
position ---------------------^
insert(position, (size_t)5, 6);
(If the operation won't preserve capacity, the buffer would look like this |1|2|6|6|6|6|6|3|4|)
RESULTING circular buffer |6|6|6|6|3|4| - capacity: 6, size: 6
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::insert iterator  pos  )  [inline]
 

Insert a new element with the default value before the given position.

Postcondition:
value_type() will be inserted at the position pos.
If the circular buffer is full, the first (leftmost) element will be removed.
Returns:
iterator to the inserted element.
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::insert iterator  pos,
param_value_type  item
[inline]
 

Insert the item before the given position.

Precondition:
Valid pos iterator.
Postcondition:
The item will be inserted at the position pos.
If the circular buffer is full, the first (leftmost) element will be removed.
Returns:
iterator to the inserted element.
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
size_type boost::circular_buffer< T, Alloc >::max_size  )  const [inline]
 

Return the largest possible size (or capacity) of the circular buffer.

template<class T, class Alloc>
circular_buffer<T, Alloc>& boost::circular_buffer< T, Alloc >::operator= const circular_buffer< T, Alloc > &  cb  )  [inline]
 

Assignment operator.

Postcondition:
*this == cb
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

template<class T, class Alloc>
return_value_type boost::circular_buffer< T, Alloc >::operator[] size_type  index  )  const [inline]
 

Return the element at the index position.

Precondition:
*(this).size() > index

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
reference boost::circular_buffer< T, Alloc >::operator[] size_type  index  )  [inline]
 

Return the element at the index position.

Precondition:
*(this).size() > index

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::pop_back  )  [inline]
 

Remove the last (rightmost) element.

Precondition:
!*(this).empty()

iterator it = ((*this).end() - 1)

Postcondition:
((*this).end() - 1) != it
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::pop_front  )  [inline]
 

Remove the first (leftmost) element.

Precondition:
!*(this).empty()

iterator it = (*this).begin()

Postcondition:
(*this).begin() != it
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::push_back  )  [inline]
 

Insert a new element with the default value at the end.

Postcondition:
(*this).back() == value_type()
If the circular buffer is full, the first (leftmost) element will be removed.
Exceptions:
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::push_back param_value_type  item  )  [inline]
 

Insert a new element at the end.

Postcondition:
(*this).back() == item
If the circular buffer is full, the first (leftmost) element will be removed.
Exceptions:
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::push_front  )  [inline]
 

Insert a new element with the default value at the start.

Postcondition:
(*this).front() == value_type()
If the circular buffer is full, the last (rightmost) element will be removed.
Exceptions:
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::push_front param_value_type  item  )  [inline]
 

Insert a new element at the start.

Postcondition:
(*this).front() == item
If the circular buffer is full, the last (rightmost) element will be removed.
Exceptions:
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
const_reverse_iterator boost::circular_buffer< T, Alloc >::rbegin  )  const [inline]
 

Return a const reverse iterator pointing to the beginning of the reversed circular buffer.

template<class T, class Alloc>
reverse_iterator boost::circular_buffer< T, Alloc >::rbegin  )  [inline]
 

Return a reverse iterator pointing to the beginning of the reversed circular buffer.

template<class T, class Alloc>
const_reverse_iterator boost::circular_buffer< T, Alloc >::rend  )  const [inline]
 

Return a const reverse iterator pointing to the end of the reversed circular buffer.

template<class T, class Alloc>
reverse_iterator boost::circular_buffer< T, Alloc >::rend  )  [inline]
 

Return a reverse iterator pointing to the end of the reversed circular buffer.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::resize size_type  new_size,
param_value_type  item = T(),
bool  remove_front = true
[inline]
 

Change the size of the circular buffer.

Parameters:
new_size The new size.
item See the postcondition.
remove_front This parameter plays its role only if the current number of elements stored in the circular buffer is greater than the desired new capacity. If set to true then the first (leftmost) elements will be removed. If set to false then the last (leftmost) elements will be removed.
Postcondition:
(*this).size() == new_size
If the new size is greater than the current size, the rest of the circular buffer is filled with copies of item. In case the resulting size exceeds the current capacity the capacity is set to new_size. If the new size is lower than the current size then ((*this).size() - new_size) elements will be removed according to the remove_front parameter.
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
template<class InputIterator>
void boost::circular_buffer< T, Alloc >::rinsert iterator  pos,
InputIterator  first,
InputIterator  last
[inline]
 

Insert the range [first, last) before the given position.

Precondition:
Valid pos iterator and valid range [first, last).
Postcondition:
This operation preserves the capacity of the circular buffer. If the insertion would result in exceeding the capacity of the circular buffer then the necessary number of elements from the end (right) of the circular buffer will be removed or not the whole range will be inserted or both. In case the whole range cannot be inserted it will be inserted just some elements from the beginning (left) of the range (see the example).
Example:
array to insert: int array[] = { 5, 6, 7, 8, 9 };
original circular buffer |1|2|3|4| | | - capacity: 6, size: 4
position ---------------------^
insert(position, array, array + 5);
(If the operation won't preserve capacity, the buffer would look like this |1|2|5|6|7|8|9|3|4|)
RESULTING circular buffer |1|2|5|6|7|8| - capacity: 6, size: 6
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::rinsert iterator  pos,
size_type  n,
param_value_type  item
[inline]
 

Insert n copies of the item before the given position.

Precondition:
Valid pos iterator.
Postcondition:
This operation preserves the capacity of the circular buffer. If the insertion would result in exceeding the capacity of the circular buffer then the necessary number of elements from the end (right) of the circular buffer will be removed or not all n elements will be inserted or both.
Example:
original circular buffer |1|2|3|4| | | - capacity: 6, size: 4
position ---------------------^
insert(position, (size_t)5, 6);
(If the operation won't preserve capacity, the buffer would look like this |1|2|6|6|6|6|6|3|4|)
RESULTING circular buffer |1|2|6|6|6|6| - capacity: 6, size: 6
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::rinsert iterator  pos  )  [inline]
 

Insert a new element with the default value before the given position.

Postcondition:
value_type() will be inserted at the position pos.
If the circular buffer is full, the last (rightmost) element will be removed.
Returns:
iterator to the inserted element.
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
iterator boost::circular_buffer< T, Alloc >::rinsert iterator  pos,
param_value_type  item
[inline]
 

Insert an item before the given position.

Precondition:
Valid pos iterator.
Postcondition:
The item will be inserted at the position pos.
If the circular buffer is full, the last element (rightmost) will be removed.
Returns:
iterator to the inserted element.
Exceptions:
Whatever T::T(const T&) throws.
Whatever T::operator = (const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::set_capacity size_type  new_capacity,
bool  remove_front = true
[inline]
 

Change the capacity of the circular buffer.

Parameters:
new_capacity The new capacity.
remove_front This parameter plays its role only if the current number of elements stored in the circular buffer is greater than the desired new capacity. If set to true then the first (leftmost) elements will be removed. If set to false then the last (leftmost) elements will be removed.
Postcondition:
(*this).capacity() == new_capacity
If the current number of elements stored in the circular buffer is greater than the desired new capacity then ((*this).size() - new_capacity) elements will be removed according to the remove_front parameter.
Exceptions:
An allocation error if memory is exhausted (std::bad_alloc if standard allocator is used).
Whatever T::T(const T&) throws.
Note:
For iterator invalidation see the documentation.

Reimplemented in boost::circular_buffer_space_optimized< T, Alloc >.

template<class T, class Alloc>
size_type boost::circular_buffer< T, Alloc >::size  )  const [inline]
 

Return the number of elements currently stored in the circular buffer.

template<class T, class Alloc>
void boost::circular_buffer< T, Alloc >::swap circular_buffer< T, Alloc > &  cb  )  [inline]
 

Swap the contents of two circular buffers.

Postcondition:
this contains elements of cb and vice versa.
Note:
For iterator invalidation see the documentation.