TwiceAsNice  2019-02-18
Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
boost::circular_buffer_space_optimized< T, Alloc > Class Template Reference

Space optimized circular buffer container adaptor. More...

#include <space_optimized.hpp>

Inheritance diagram for boost::circular_buffer_space_optimized< T, Alloc >:
Inheritance graph
Collaboration diagram for boost::circular_buffer_space_optimized< T, Alloc >:
Collaboration graph

Public Types

typedef circular_buffer< T, Alloc >::value_type value_type
 
typedef circular_buffer< T, Alloc >::pointer pointer
 
typedef circular_buffer< T, Alloc >::const_pointer const_pointer
 
typedef circular_buffer< T, Alloc >::reference reference
 
typedef circular_buffer< T, Alloc >::const_reference const_reference
 
typedef circular_buffer< T, Alloc >::size_type size_type
 
typedef circular_buffer< T, Alloc >::difference_type difference_type
 
typedef circular_buffer< T, Alloc >::allocator_type allocator_type
 
typedef circular_buffer< T, Alloc >::const_iterator const_iterator
 
typedef circular_buffer< T, Alloc >::iterator iterator
 
typedef circular_buffer< T, Alloc >::const_reverse_iterator const_reverse_iterator
 
typedef circular_buffer< T, Alloc >::reverse_iterator reverse_iterator
 
typedef circular_buffer< T, Alloc >::array_range array_range
 
typedef circular_buffer< T, Alloc >::const_array_range const_array_range
 
typedef circular_buffer< T, Alloc >::param_value_type param_value_type
 
typedef circular_buffer< T, Alloc >::return_value_type return_value_type
 
typedef cb_details::capacity_control< size_typecapacity_type
 Capacity controller of the space optimized circular buffer. More...
 

Public Member Functions

bool full () const
 Is the circular_buffer_space_optimized full? More...
 
size_type reserve () const
 Get the maximum number of elements which can be inserted into the circular_buffer_space_optimized without overwriting any of already stored elements. More...
 
const capacity_typecapacity () const
 Get the capacity of the circular_buffer_space_optimized. More...
 
void set_capacity (const capacity_type &capacity_ctrl)
 Change the capacity (and the minimal guaranteed amount of allocated memory) of the circular_buffer_space_optimized. More...
 
void resize (size_type new_size, param_value_type item=value_type())
 Change the size of the circular_buffer_space_optimized. More...
 
void rset_capacity (const capacity_type &capacity_ctrl)
 Change the capacity (and the minimal guaranteed amount of allocated memory) of the circular_buffer_space_optimized. More...
 
void rresize (size_type new_size, param_value_type item=value_type())
 Change the size of the circular_buffer_space_optimized. More...
 
 circular_buffer_space_optimized (const allocator_type &alloc=allocator_type())
 Create an empty space optimized circular buffer with a maximum capacity. More...
 
 circular_buffer_space_optimized (capacity_type capacity_ctrl, const allocator_type &alloc=allocator_type())
 Create an empty space optimized circular buffer with the specified capacity. More...
 
 circular_buffer_space_optimized (capacity_type capacity_ctrl, param_value_type item, const allocator_type &alloc=allocator_type())
 Create a full space optimized circular buffer with the specified capacity filled with capacity_ctrl.capacity() copies of item. More...
 
 circular_buffer_space_optimized (capacity_type capacity_ctrl, size_type n, param_value_type item, const allocator_type &alloc=allocator_type())
 Create a space optimized circular buffer with the specified capacity filled with n copies of item. More...
 
 circular_buffer_space_optimized (const circular_buffer_space_optimized< T, Alloc > &cb)
 The copy constructor. More...
 
template<class InputIterator >
 circular_buffer_space_optimized (InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
 Create a full space optimized circular buffer filled with a copy of the range. More...
 
template<class InputIterator >
 circular_buffer_space_optimized (capacity_type capacity_ctrl, InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
 Create a space optimized circular buffer with the specified capacity (and the minimal guaranteed amount of allocated memory) filled with a copy of the range. More...
 
circular_buffer_space_optimized< T, Alloc > & operator= (const circular_buffer_space_optimized< T, Alloc > &cb)
 The assign operator. More...
 
void assign (size_type n, param_value_type item)
 Assign n items into the space optimized circular buffer. More...
 
void assign (capacity_type capacity_ctrl, size_type n, param_value_type item)
 Assign n items into the space optimized circular buffer specifying the capacity. More...
 
template<class InputIterator >
void assign (InputIterator first, InputIterator last)
 Assign a copy of the range into the space optimized circular buffer. More...
 
template<class InputIterator >
void assign (capacity_type capacity_ctrl, InputIterator first, InputIterator last)
 Assign a copy of the range into the space optimized circular buffer specifying the capacity. More...
 
void swap (circular_buffer_space_optimized< T, Alloc > &cb)
 Swap the contents of two space optimized circular buffers. More...
 
void push_back (param_value_type item=value_type())
 Insert a new element at the end of the space optimized circular buffer. More...
 
void push_front (param_value_type item=value_type())
 Insert a new element at the beginning of the space optimized circular buffer. More...
 
void pop_back ()
 Remove the last element from the space optimized circular buffer. More...
 
void pop_front ()
 Remove the first element from the space optimized circular buffer. More...
 
iterator insert (iterator pos, param_value_type item=value_type())
 Insert an element at the specified position. More...
 
void insert (iterator pos, size_type n, param_value_type item)
 Insert n copies of the item at the specified position. More...
 
template<class InputIterator >
void insert (iterator pos, InputIterator first, InputIterator last)
 Insert the range [first, last) at the specified position. More...
 
iterator rinsert (iterator pos, param_value_type item=value_type())
 Insert an element before the specified position. More...
 
void rinsert (iterator pos, size_type n, param_value_type item)
 Insert n copies of the item before the specified position. More...
 
template<class InputIterator >
void rinsert (iterator pos, InputIterator first, InputIterator last)
 Insert the range [first, last) before the specified position. More...
 
iterator erase (iterator pos)
 Remove an element at the specified position. More...
 
iterator erase (iterator first, iterator last)
 Erase the range [first, last). More...
 
iterator rerase (iterator pos)
 Remove an element at the specified position. More...
 
iterator rerase (iterator first, iterator last)
 Erase the range [first, last). More...
 
void clear ()
 Remove all stored elements from the space optimized circular buffer. More...
 

Private Member Functions

void adjust_min_capacity ()
 Adjust the amount of allocated memory. More...
 
size_type ensure_reserve (size_type new_capacity, size_type size) const
 Ensure the reserve for possible growth up. More...
 
void check_low_capacity (size_type n=1)
 Check for low capacity. More...
 
void check_high_capacity ()
 Check for high capacity. More...
 
void reduce_capacity (const true_type &)
 Specialized method for reducing the capacity. More...
 
void reduce_capacity (const false_type &)
 Specialized method for reducing the capacity. More...
 
template<class IntegralType >
void insert (const iterator &pos, IntegralType n, IntegralType item, const true_type &)
 Specialized insert method. More...
 
template<class Iterator >
void insert (const iterator &pos, Iterator first, Iterator last, const false_type &)
 Specialized insert method. More...
 
template<class IntegralType >
void rinsert (const iterator &pos, IntegralType n, IntegralType item, const true_type &)
 Specialized rinsert method. More...
 
template<class Iterator >
void rinsert (const iterator &pos, Iterator first, Iterator last, const false_type &)
 Specialized rinsert method. More...
 
- Private Member Functions inherited from boost::circular_buffer< T, Alloc >
allocator_type get_allocator () const
 Get the allocator. More...
 
allocator_typeget_allocator ()
 Get the allocator reference. More...
 
iterator begin ()
 Get the iterator pointing to the beginning of the circular_buffer. More...
 
iterator end ()
 Get the iterator pointing to the end of the circular_buffer. More...
 
const_iterator begin () const
 Get the const iterator pointing to the beginning of the circular_buffer. More...
 
const_iterator end () const
 Get the const iterator pointing to the end of the circular_buffer. More...
 
reverse_iterator rbegin ()
 Get the iterator pointing to the beginning of the "reversed" circular_buffer. More...
 
reverse_iterator rend ()
 Get the iterator pointing to the end of the "reversed" circular_buffer. More...
 
const_reverse_iterator rbegin () const
 Get the const iterator pointing to the beginning of the "reversed" circular_buffer. More...
 
const_reverse_iterator rend () const
 Get the const iterator pointing to the end of the "reversed" circular_buffer. More...
 
reference operator[] (size_type index)
 Get the element at the index position. More...
 
return_value_type operator[] (size_type index) const
 Get the element at the index position. More...
 
reference at (size_type index)
 Get the element at the index position. More...
 
return_value_type at (size_type index) const
 Get the element at the index position. More...
 
reference front ()
 Get the first element. More...
 
reference back ()
 Get the last element. More...
 
return_value_type front () const
 Get the first element. More...
 
return_value_type back () const
 Get the last element. More...
 
array_range array_one ()
 Get the first continuous array of the internal buffer. More...
 
array_range array_two ()
 Get the second continuous array of the internal buffer. More...
 
const_array_range array_one () const
 Get the first continuous array of the internal buffer. More...
 
const_array_range array_two () const
 Get the second continuous array of the internal buffer. More...
 
pointer linearize ()
 Linearize the internal buffer into a continuous array. More...
 
size_type size () const
 Get the number of elements currently stored in the circular_buffer. More...
 
size_type max_size () const
 Get the largest possible size or capacity of the circular_buffer. (It depends on allocator's max_size()). More...
 
bool empty () const
 Is the circular_buffer empty? More...
 
bool full () const
 Is the circular_buffer full? More...
 
size_type reserve () const
 Get the maximum number of elements which can be inserted into the circular_buffer without overwriting any of already stored elements. More...
 
capacity_type capacity () const
 Get the capacity of the circular_buffer. More...
 
void set_capacity (capacity_type new_capacity)
 Change the capacity of the circular_buffer. More...
 
void resize (size_type new_size, param_value_type item=value_type())
 Change the size of the circular_buffer. More...
 
void rset_capacity (capacity_type new_capacity)
 Change the capacity of the circular_buffer. More...
 
void rresize (size_type new_size, param_value_type item=value_type())
 Change the size of the circular_buffer. More...
 
 circular_buffer (const allocator_type &alloc=allocator_type())
 Create an empty circular_buffer with a maximum capacity. More...
 
 circular_buffer (capacity_type capacity, const allocator_type &alloc=allocator_type())
 Create an empty circular_buffer with the specified capacity. More...
 
 circular_buffer (size_type n, param_value_type item, const allocator_type &alloc=allocator_type())
 Create a full circular_buffer with the specified capacity and filled with n copies of item. More...
 
 circular_buffer (capacity_type capacity, size_type n, param_value_type item, const allocator_type &alloc=allocator_type())
 Create a circular_buffer with the specified capacity and filled with n copies of item. More...
 
 circular_buffer (const circular_buffer< T, Alloc > &cb)
 The copy constructor. More...
 
template<class InputIterator >
 circular_buffer (InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
 Create a full circular_buffer filled with a copy of the range. More...
 
template<class InputIterator >
 circular_buffer (capacity_type capacity, InputIterator first, InputIterator last, const allocator_type &alloc=allocator_type())
 Create a circular_buffer with the specified capacity and filled with a copy of the range. More...
 
 ~circular_buffer ()
 The destructor. More...
 
circular_buffer< T, Alloc > & operator= (const circular_buffer< T, Alloc > &cb)
 The assign operator. More...
 
void assign (size_type n, param_value_type item)
 Assign n items into the circular_buffer. More...
 
void assign (capacity_type capacity, size_type n, param_value_type item)
 Assign n items into the circular_buffer specifying the capacity. More...
 
template<class InputIterator >
void assign (InputIterator first, InputIterator last)
 Assign a copy of the range into the circular_buffer. More...
 
template<class InputIterator >
void assign (capacity_type capacity, InputIterator first, InputIterator last)
 Assign a copy of the range into the circular_buffer specifying the capacity. More...
 
void swap (circular_buffer< T, Alloc > &cb)
 Swap the contents of two circular_buffers. More...
 
void push_back (param_value_type item=value_type())
 Insert a new element at the end of the circular_buffer. More...
 
void push_front (param_value_type item=value_type())
 Insert a new element at the beginning of the circular_buffer. More...
 
void pop_back ()
 Remove the last element from the circular_buffer. More...
 
void pop_front ()
 Remove the first element from the circular_buffer. More...
 
iterator insert (iterator pos, param_value_type item=value_type())
 Insert an element at the specified position. More...
 
void insert (iterator pos, size_type n, param_value_type item)
 Insert n copies of the item at the specified position. More...
 
template<class InputIterator >
void insert (iterator pos, InputIterator first, InputIterator last)
 Insert the range [first, last) at the specified position. More...
 
iterator rinsert (iterator pos, param_value_type item=value_type())
 Insert an element before the specified position. More...
 
void rinsert (iterator pos, size_type n, param_value_type item)
 Insert n copies of the item before the specified position. More...
 
template<class InputIterator >
void rinsert (iterator pos, InputIterator first, InputIterator last)
 Insert the range [first, last) before the specified position. More...
 
iterator erase (iterator pos)
 Remove an element at the specified position. More...
 
iterator erase (iterator first, iterator last)
 Erase the range [first, last). More...
 
iterator rerase (iterator pos)
 Remove an element at the specified position. More...
 
iterator rerase (iterator first, iterator last)
 Erase the range [first, last). More...
 
void clear ()
 Remove all stored elements from the circular_buffer. More...
 

Static Private Member Functions

static size_type init_capacity (const capacity_type &capacity_ctrl, size_type n)
 Determine the initial capacity. More...
 
template<class IntegralType >
static size_type init_capacity (const capacity_type &capacity_ctrl, IntegralType n, IntegralType item, const true_type &)
 Specialized method for determining the initial capacity. More...
 
template<class Iterator >
static size_type init_capacity (const capacity_type &capacity_ctrl, Iterator first, Iterator last, const false_type &)
 Specialized method for determining the initial capacity. More...
 
template<class InputIterator >
static size_type init_capacity (const capacity_type &capacity_ctrl, InputIterator first, InputIterator last, const std::input_iterator_tag &)
 Specialized method for determining the initial capacity. More...
 
template<class ForwardIterator >
static size_type init_capacity (const capacity_type &capacity_ctrl, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &)
 Specialized method for determining the initial capacity. More...
 

Private Attributes

capacity_type m_capacity_ctrl
 The capacity controller of the space optimized circular buffer. More...
 

Additional Inherited Members

- Private Types inherited from boost::circular_buffer< T, Alloc >
typedef Alloc::value_type value_type
 The type of elements stored in the circular_buffer. More...
 
typedef Alloc::pointer pointer
 A pointer to an element. More...
 
typedef Alloc::const_pointer const_pointer
 A const pointer to the element. More...
 
typedef Alloc::reference reference
 A reference to an element. More...
 
typedef Alloc::const_reference const_reference
 A const reference to an element. More...
 
typedef Alloc::difference_type difference_type
 The distance type. More...
 
typedef Alloc::size_type size_type
 The size type. More...
 
typedef Alloc allocator_type
 The type of an allocator used in the circular_buffer. More...
 
typedef cb_details::iterator< circular_buffer< T, Alloc >, cb_details::const_traits< Alloc > > const_iterator
 A const (random access) iterator used to iterate through the circular_buffer. More...
 
typedef cb_details::iterator< circular_buffer< T, Alloc >, cb_details::nonconst_traits< Alloc > > iterator
 A (random access) iterator used to iterate through the circular_buffer. More...
 
typedef boost::reverse_iterator< const_iteratorconst_reverse_iterator
 A const iterator used to iterate backwards through a circular_buffer. More...
 
typedef boost::reverse_iterator< iteratorreverse_iterator
 An iterator used to iterate backwards through a circular_buffer. More...
 
typedef std::pair< pointer, size_typearray_range
 An array range. More...
 
typedef std::pair< const_pointer, size_typeconst_array_range
 A range of a const array. More...
 
typedef size_type capacity_type
 The capacity type. More...
 
typedef call_traits< value_type >::param_type param_value_type
 
typedef call_traits< value_type >::param_type return_value_type
 

Detailed Description

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

Space optimized circular buffer container adaptor.

For detailed documentation of the space_optimized_circular_buffer visit: http://www.boost.org/libs/circular_buffer/doc/space_optimized.html

Member Typedef Documentation

◆ allocator_type

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

◆ array_range

template<class T , class Alloc >
typedef circular_buffer<T, Alloc>::array_range boost::circular_buffer_space_optimized< T, Alloc >::array_range

◆ capacity_type

template<class T , class Alloc >
typedef cb_details::capacity_control<size_type> boost::circular_buffer_space_optimized< T, Alloc >::capacity_type

Capacity controller of the space optimized circular buffer.

class capacity_control {
   size_type m_capacity;
   size_type m_min_capacity;
public:
   capacity_control(size_type capacity, size_type min_capacity = 0) : m_capacity(capacity), m_min_capacity(min_capacity) {};
   size_type capacity() const { return m_capacity; }
   size_type min_capacity() const { return m_min_capacity; }
   operator size_type() const { return m_capacity; }
};
Precondition
capacity >= min_capacity

The capacity() represents the capacity of the circular_buffer_space_optimized and the min_capacity() determines the minimal allocated size of its internal buffer.

The converting constructor of the capacity_control allows implicit conversion from size_type-like types which ensures compatibility of creating an instance of the circular_buffer_space_optimized with other STL containers. On the other hand the operator size_type() provides implicit conversion to the size_type which allows to treat the capacity of the circular_buffer_space_optimized the same way as in the circular_buffer.

◆ const_array_range

template<class T , class Alloc >
typedef circular_buffer<T, Alloc>::const_array_range boost::circular_buffer_space_optimized< T, Alloc >::const_array_range

◆ const_iterator

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

◆ const_pointer

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

◆ const_reference

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

◆ const_reverse_iterator

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

◆ difference_type

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

◆ iterator

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

◆ param_value_type

template<class T , class Alloc >
typedef circular_buffer<T, Alloc>::param_value_type boost::circular_buffer_space_optimized< T, Alloc >::param_value_type

◆ pointer

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

◆ reference

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

◆ return_value_type

template<class T , class Alloc >
typedef circular_buffer<T, Alloc>::return_value_type boost::circular_buffer_space_optimized< T, Alloc >::return_value_type

◆ reverse_iterator

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

◆ size_type

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

◆ value_type

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

Constructor & Destructor Documentation

◆ circular_buffer_space_optimized() [1/7]

template<class T , class Alloc >
boost::circular_buffer_space_optimized< T, Alloc >::circular_buffer_space_optimized ( const allocator_type alloc = allocator_type())
inlineexplicit

Create an empty space optimized circular buffer with a maximum capacity.

Postcondition
capacity().capacity() == max_size() && capacity().min_capacity() == 0 && size() == 0

There is no memory allocated in the internal buffer.
Parameters
allocThe allocator.
Exceptions
Nothing.
Complexity
Constant.

◆ circular_buffer_space_optimized() [2/7]

template<class T , class Alloc >
boost::circular_buffer_space_optimized< T, Alloc >::circular_buffer_space_optimized ( capacity_type  capacity_ctrl,
const allocator_type alloc = allocator_type() 
)
inlineexplicit

Create an empty space optimized circular buffer with the specified capacity.

Postcondition
capacity() == capacity_ctrl && size() == 0

The amount of allocated memory in the internal buffer is capacity_ctrl.min_capacity().
Parameters
capacity_ctrlThe capacity controller representing the maximum number of elements which can be stored in the circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
Complexity
Constant.

◆ circular_buffer_space_optimized() [3/7]

template<class T , class Alloc >
boost::circular_buffer_space_optimized< T, Alloc >::circular_buffer_space_optimized ( capacity_type  capacity_ctrl,
param_value_type  item,
const allocator_type alloc = allocator_type() 
)
inline

Create a full space optimized circular buffer with the specified capacity filled with capacity_ctrl.capacity() copies of item.

Postcondition
capacity() == capacity_ctrl && full() && (*this)[0] == item && (*this)[1] == item && ... && (*this) [capacity_ctrl.capacity() - 1] == item

The amount of allocated memory in the internal buffer is capacity_ctrl.capacity().
Parameters
capacity_ctrlThe capacity controller representing the maximum number of elements which can be stored in the circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
itemThe element the created circular_buffer_space_optimized will be filled with.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in the capacity_ctrl.capacity()).

◆ circular_buffer_space_optimized() [4/7]

template<class T , class Alloc >
boost::circular_buffer_space_optimized< T, Alloc >::circular_buffer_space_optimized ( capacity_type  capacity_ctrl,
size_type  n,
param_value_type  item,
const allocator_type alloc = allocator_type() 
)
inline

Create a space optimized circular buffer with the specified capacity filled with n copies of item.

Precondition
capacity_ctrl.capacity() >= n
Postcondition
capacity() == capacity_ctrl && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] == item

The amount of allocated memory in the internal buffer is max[n, capacity_ctrl.min_capacity()].
Parameters
capacity_ctrlThe capacity controller representing the maximum number of elements which can be stored in the circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
nThe number of elements the created circular_buffer_space_optimized will be filled with.
itemThe element the created circular_buffer_space_optimized will be filled with.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in the n).

◆ circular_buffer_space_optimized() [5/7]

template<class T , class Alloc >
boost::circular_buffer_space_optimized< T, Alloc >::circular_buffer_space_optimized ( const circular_buffer_space_optimized< T, Alloc > &  cb)
inline

The copy constructor.

Creates a copy of the specified circular_buffer_space_optimized.

Postcondition
*this == cb

The amount of allocated memory in the internal buffer is cb.size().
Parameters
cbThe circular_buffer_space_optimized to be copied.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in the size of cb).

◆ circular_buffer_space_optimized() [6/7]

template<class T , class Alloc >
template<class InputIterator >
boost::circular_buffer_space_optimized< T, Alloc >::circular_buffer_space_optimized ( InputIterator  first,
InputIterator  last,
const allocator_type alloc = allocator_type() 
)
inline

Create a full space optimized circular buffer filled with a copy of the range.

Precondition
Valid range [first, last).
first and last have to meet the requirements of InputIterator.
Postcondition
capacity().capacity() == std::distance(first, last) && capacity().min_capacity() == 0 && full() && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... && (*this)[std::distance(first, last) - 1] == *(last - 1)

The amount of allocated memory in the internal buffer is std::distance(first, last).
Parameters
firstThe beginning of the range to be copied.
lastThe end of the range to be copied.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in the std::distance(first, last)).

◆ circular_buffer_space_optimized() [7/7]

template<class T , class Alloc >
template<class InputIterator >
boost::circular_buffer_space_optimized< T, Alloc >::circular_buffer_space_optimized ( capacity_type  capacity_ctrl,
InputIterator  first,
InputIterator  last,
const allocator_type alloc = allocator_type() 
)
inline

Create a space optimized circular buffer with the specified capacity (and the minimal guaranteed amount of allocated memory) filled with a copy of the range.

Precondition
Valid range [first, last).
first and last have to meet the requirements of InputIterator.
Postcondition
capacity() == capacity_ctrl && size() <= std::distance(first, last) && (*this)[0]== (last - capacity_ctrl.capacity()) && (*this)[1] == *(last - capacity_ctrl.capacity() + 1) && ... && (*this)[capacity_ctrl.capacity() - 1] == *(last - 1)

If the number of items to be copied from the range [first, last) is greater than the specified capacity_ctrl.capacity() then only elements from the range [last - capacity_ctrl.capacity(), last) will be copied.

The amount of allocated memory in the internal buffer is max[capacity_ctrl.min_capacity(), min[capacity_ctrl.capacity(), std::distance(first, last)]].
Parameters
capacity_ctrlThe capacity controller representing the maximum number of elements which can be stored in the circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
firstThe beginning of the range to be copied.
lastThe end of the range to be copied.
allocThe allocator.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Complexity
Linear (in std::distance(first, last); in min[capacity_ctrl.capacity(), std::distance(first, last)] if the InputIterator is a RandomAccessIterator).

Member Function Documentation

◆ adjust_min_capacity()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::adjust_min_capacity ( )
inlineprivate

Adjust the amount of allocated memory.

◆ assign() [1/4]

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::assign ( size_type  n,
param_value_type  item 
)
inline

Assign n items into the space optimized circular buffer.

The content of the circular_buffer_space_optimized will be removed and replaced with n copies of the item.

Postcondition
capacity().capacity() == n && capacity().min_capacity() == 0 && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] == item

The amount of allocated memory in the internal buffer is n.
Parameters
nThe number of elements the circular_buffer_space_optimized will be filled with.
itemThe element the circular_buffer_space_optimized will be filled with.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the n).
See also
operator=, assign(capacity_type, size_type, const_reference), assign(InputIterator, InputIterator), assign(capacity_type, InputIterator, InputIterator)

◆ assign() [2/4]

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::assign ( capacity_type  capacity_ctrl,
size_type  n,
param_value_type  item 
)
inline

Assign n items into the space optimized circular buffer specifying the capacity.

The capacity of the circular_buffer_space_optimized will be set to the specified value and the content of the circular_buffer_space_optimized will be removed and replaced with n copies of the item.

Precondition
capacity_ctrl.capacity() >= n
Postcondition
capacity() == capacity_ctrl && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] == item

The amount of allocated memory will be max[n, capacity_ctrl.min_capacity()].
Parameters
capacity_ctrlThe new capacity controller.
nThe number of elements the circular_buffer_space_optimized will be filled with.
itemThe element the circular_buffer_space_optimized will be filled with.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the n).
See also
operator=, assign(size_type, const_reference), assign(InputIterator, InputIterator), assign(capacity_type, InputIterator, InputIterator)

◆ assign() [3/4]

template<class T , class Alloc >
template<class InputIterator >
void boost::circular_buffer_space_optimized< T, Alloc >::assign ( InputIterator  first,
InputIterator  last 
)
inline

Assign a copy of the range into the space optimized circular buffer.

The content of the circular_buffer_space_optimized will be removed and replaced with copies of elements from the specified range.

Precondition
Valid range [first, last).
first and last have to meet the requirements of InputIterator.
Postcondition
capacity().capacity() == std::distance(first, last) && capacity().min_capacity() == 0 && size() == std::distance(first, last) && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... && (*this)[std::distance(first, last) - 1] == *(last - 1)

The amount of allocated memory in the internal buffer is std::distance(first, last).
Parameters
firstThe beginning of the range to be copied.
lastThe end of the range to be copied.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the std::distance(first, last)).
See also
operator=, assign(size_type, const_reference), assign(capacity_type, size_type, const_reference), assign(capacity_type, InputIterator, InputIterator)

◆ assign() [4/4]

template<class T , class Alloc >
template<class InputIterator >
void boost::circular_buffer_space_optimized< T, Alloc >::assign ( capacity_type  capacity_ctrl,
InputIterator  first,
InputIterator  last 
)
inline

Assign a copy of the range into the space optimized circular buffer specifying the capacity.

The capacity of the circular_buffer_space_optimized will be set to the specified value and the content of the circular_buffer_space_optimized will be removed and replaced with copies of elements from the specified range.

Precondition
Valid range [first, last).
first and last have to meet the requirements of InputIterator.
Postcondition
capacity() == capacity_ctrl && size() <= std::distance(first, last) && (*this)[0]== *(last - capacity) && (*this)[1] == *(last - capacity + 1) && ... && (*this)[capacity - 1] == *(last - 1)

If the number of items to be copied from the range [first, last) is greater than the specified capacity then only elements from the range [last - capacity, last) will be copied.

The amount of allocated memory in the internal buffer is max[std::distance(first, last), capacity_ctrl.min_capacity()].
Parameters
capacity_ctrlThe new capacity controller.
firstThe beginning of the range to be copied.
lastThe end of the range to be copied.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in std::distance(first, last); in min[capacity_ctrl.capacity(), std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
See also
operator=, assign(size_type, const_reference), assign(capacity_type, size_type, const_reference), assign(InputIterator, InputIterator)

◆ capacity()

template<class T , class Alloc >
const capacity_type& boost::circular_buffer_space_optimized< T, Alloc >::capacity ( ) const
inline

Get the capacity of the circular_buffer_space_optimized.

Returns
The capacity controller representing the maximum number of elements which can be stored in the circular_buffer_space_optimized and the minimal allocated size of the internal buffer.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer_space_optimized).
See also
reserve(), size(), max_size(), set_capacity(const capacity_type&)

◆ check_high_capacity()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::check_high_capacity ( )
inlineprivate

Check for high capacity.

◆ check_low_capacity()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::check_low_capacity ( size_type  n = 1)
inlineprivate

Check for low capacity.

◆ clear()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::clear ( void  )
inline

Remove all stored elements from the space optimized circular buffer.

Postcondition
size() == 0

The amount of allocated memory in the internal buffer may be predictively decreased.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
~circular_buffer_space_optimized(), erase(iterator), erase(iterator, iterator), rerase(iterator), rerase(iterator, iterator)

◆ ensure_reserve()

template<class T , class Alloc >
size_type boost::circular_buffer_space_optimized< T, Alloc >::ensure_reserve ( size_type  new_capacity,
size_type  size 
) const
inlineprivate

Ensure the reserve for possible growth up.

◆ erase() [1/2]

template<class T , class Alloc >
iterator boost::circular_buffer_space_optimized< T, Alloc >::erase ( iterator  pos)
inline

Remove an element at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer_space_optimized (but not an end()).
Postcondition
The element at the position pos is removed.

The amount of allocated memory in the internal buffer may be predictively decreased.
Parameters
posAn iterator pointing at the element to be removed.
Returns
Iterator to the first element remaining beyond the removed element or end() if no such element exists.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
erase(iterator, iterator), rerase(iterator), rerase(iterator, iterator), clear()

◆ erase() [2/2]

template<class T , class Alloc >
iterator boost::circular_buffer_space_optimized< T, Alloc >::erase ( iterator  first,
iterator  last 
)
inline

Erase the range [first, last).

Precondition
Valid range [first, last).
Postcondition
The elements from the range [first, last) are removed. (If first == last nothing is removed.)

The amount of allocated memory in the internal buffer may be predictively decreased.
Parameters
firstThe beginning of the range to be removed.
lastThe end of the range to be removed.
Returns
Iterator to the first element remaining beyond the removed elements or end() if no such element exists.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
erase(iterator), rerase(iterator), rerase(iterator, iterator), clear()

◆ full()

template<class T , class Alloc >
bool boost::circular_buffer_space_optimized< T, Alloc >::full ( ) const
inline

Is the circular_buffer_space_optimized full?

Returns
true if the number of elements stored in the circular_buffer_space_optimized equals the capacity of the circular_buffer_space_optimized; false otherwise.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer_space_optimized).
See also
empty()

◆ init_capacity() [1/5]

template<class T , class Alloc >
static size_type boost::circular_buffer_space_optimized< T, Alloc >::init_capacity ( const capacity_type capacity_ctrl,
size_type  n 
)
inlinestaticprivate

Determine the initial capacity.

◆ init_capacity() [2/5]

template<class T , class Alloc >
template<class IntegralType >
static size_type boost::circular_buffer_space_optimized< T, Alloc >::init_capacity ( const capacity_type capacity_ctrl,
IntegralType  n,
IntegralType  item,
const true_type &   
)
inlinestaticprivate

Specialized method for determining the initial capacity.

◆ init_capacity() [3/5]

template<class T , class Alloc >
template<class Iterator >
static size_type boost::circular_buffer_space_optimized< T, Alloc >::init_capacity ( const capacity_type capacity_ctrl,
Iterator  first,
Iterator  last,
const false_type &   
)
inlinestaticprivate

Specialized method for determining the initial capacity.

◆ init_capacity() [4/5]

template<class T , class Alloc >
template<class InputIterator >
static size_type boost::circular_buffer_space_optimized< T, Alloc >::init_capacity ( const capacity_type capacity_ctrl,
InputIterator  first,
InputIterator  last,
const std::input_iterator_tag &   
)
inlinestaticprivate

Specialized method for determining the initial capacity.

◆ init_capacity() [5/5]

template<class T , class Alloc >
template<class ForwardIterator >
static size_type boost::circular_buffer_space_optimized< T, Alloc >::init_capacity ( const capacity_type capacity_ctrl,
ForwardIterator  first,
ForwardIterator  last,
const std::forward_iterator_tag &   
)
inlinestaticprivate

Specialized method for determining the initial capacity.

◆ insert() [1/5]

template<class T , class Alloc >
iterator boost::circular_buffer_space_optimized< T, Alloc >::insert ( iterator  pos,
param_value_type  item = value_type() 
)
inline

Insert an element at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer_space_optimized or its end.
Postcondition
The item will be inserted at the position pos.
If the circular_buffer_space_optimized is full, the first element will be overwritten. If the circular_buffer_space_optimized is full and the pos points to begin(), then the item will not be inserted. If the capacity is 0, nothing will be inserted.

The amount of allocated memory in the internal buffer may be predictively increased.
Parameters
posAn iterator specifying the position where the item will be inserted.
itemThe element to be inserted.
Returns
Iterator to the inserted element or begin() if the item is not inserted. (See the Effect.)
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
insert(iterator, size_type, value_type), insert(iterator, InputIterator, InputIterator), rinsert(iterator, value_type), rinsert(iterator, size_type, value_type), rinsert(iterator, InputIterator, InputIterator)

◆ insert() [2/5]

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::insert ( iterator  pos,
size_type  n,
param_value_type  item 
)
inline

Insert n copies of the item at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer_space_optimized or its end.
Postcondition
The number of min[n, (pos - begin()) + reserve()] elements will be inserted at the position pos.
The number of min[pos - begin(), max[0, n - reserve()]] elements will be overwritten at the beginning of the circular_buffer_space_optimized.
(See Example for the explanation.)

The amount of allocated memory in the internal buffer may be predictively increased.
Parameters
posAn iterator specifying the position where the items will be inserted.
nThe number of items the to be inserted.
itemThe element whose copies will be inserted.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in min[capacity().capacity(), size() + n]).
Example
Consider a circular_buffer_space_optimized with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.

|1|2|3|4| | |
p —^

After inserting 5 elements at the position p:

insert(p, (size_t)5, 0);

actually only 4 elements get inserted and elements 1 and 2 are overwritten. This is due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks like this:

|0|0|0|0|3|4|

For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|0|0|0|0|0|3|4|.
See also
insert(iterator, value_type), insert(iterator, InputIterator, InputIterator), rinsert(iterator, value_type), rinsert(iterator, size_type, value_type), rinsert(iterator, InputIterator, InputIterator)

◆ insert() [3/5]

template<class T , class Alloc >
template<class InputIterator >
void boost::circular_buffer_space_optimized< T, Alloc >::insert ( iterator  pos,
InputIterator  first,
InputIterator  last 
)
inline

Insert the range [first, last) at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer_space_optimized or its end.
Valid range [first, last) where first and last meet the requirements of an InputIterator.
Postcondition
Elements from the range [first + max[0, distance(first, last) - (pos - begin()) - reserve()], last) will be inserted at the position pos.
The number of min[pos - begin(), max[0, distance(first, last) - reserve()]] elements will be overwritten at the beginning of the circular_buffer_space_optimized.
(See Example for the explanation.)

The amount of allocated memory in the internal buffer may be predictively increased.
Parameters
posAn iterator specifying the position where the range will be inserted.
firstThe beginning of the range to be inserted.
lastThe end of the range to be inserted.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in [size() + std::distance(first, last)]; in min[capacity().capacity(), size() + std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
Example
Consider a circular_buffer_space_optimized with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.

|1|2|3|4| | |
p —^

After inserting a range of elements at the position p:

int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);

actually only elements 6, 7, 8 and 9 from the specified range get inserted and elements 1 and 2 are overwritten. This is due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks like this:

|6|7|8|9|3|4|

For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|5|6|7|8|9|3|4|.
See also
insert(iterator, value_type), insert(iterator, size_type, value_type), rinsert(iterator, value_type), rinsert(iterator, size_type, value_type), rinsert(iterator, InputIterator, InputIterator)

◆ insert() [4/5]

template<class T , class Alloc >
template<class IntegralType >
void boost::circular_buffer_space_optimized< T, Alloc >::insert ( const iterator pos,
IntegralType  n,
IntegralType  item,
const true_type &   
)
inlineprivate

Specialized insert method.

◆ insert() [5/5]

template<class T , class Alloc >
template<class Iterator >
void boost::circular_buffer_space_optimized< T, Alloc >::insert ( const iterator pos,
Iterator  first,
Iterator  last,
const false_type &   
)
inlineprivate

Specialized insert method.

◆ operator=()

template<class T , class Alloc >
circular_buffer_space_optimized<T, Alloc>& boost::circular_buffer_space_optimized< T, Alloc >::operator= ( const circular_buffer_space_optimized< T, Alloc > &  cb)
inline

The assign operator.

Makes this circular_buffer_space_optimized to become a copy of the specified circular_buffer_space_optimized.

Postcondition
*this == cb

The amount of allocated memory in the internal buffer is cb.size().
Parameters
cbThe circular_buffer_space_optimized to be copied.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Strong.
Iterator Invalidation
Invalidates all iterators pointing to this circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of cb).
See also
assign(size_type, const_reference), assign(capacity_type, size_type, const_reference), assign(InputIterator, InputIterator), assign(capacity_type, InputIterator, InputIterator)

◆ pop_back()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::pop_back ( void  )
inline

Remove the last element from the space optimized circular buffer.

Precondition
!empty()
Postcondition
The last element is removed from the circular_buffer_space_optimized.

The amount of allocated memory in the internal buffer may be predictively decreased.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
pop_front(), push_back(const_reference), push_front(const_reference)

◆ pop_front()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::pop_front ( void  )
inline

Remove the first element from the space optimized circular buffer.

Precondition
!empty()
Postcondition
The first element is removed from the circular_buffer_space_optimized.

The amount of allocated memory in the internal buffer may be predictively decreased.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
pop_back(), push_back(const_reference), push_front(const_reference)

◆ push_back()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::push_back ( param_value_type  item = value_type())
inline

Insert a new element at the end of the space optimized circular buffer.

Postcondition
if capacity().capacity() > 0 then back() == item
If the circular_buffer_space_optimized is full, the first element will be removed. If the capacity is 0, nothing will be inserted.

The amount of allocated memory in the internal buffer may be predictively increased.
Parameters
itemThe element to be inserted.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
push_front(const_reference), pop_back(), pop_front()

◆ push_front()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::push_front ( param_value_type  item = value_type())
inline

Insert a new element at the beginning of the space optimized circular buffer.

Postcondition
if capacity().capacity() > 0 then front() == item
If the circular_buffer_space_optimized is full, the last element will be removed. If the capacity is 0, nothing will be inserted.

The amount of allocated memory in the internal buffer may be predictively increased.
Parameters
itemThe element to be inserted.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
push_back(const_reference), pop_back(), pop_front()

◆ reduce_capacity() [1/2]

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::reduce_capacity ( const true_type &  )
inlineprivate

Specialized method for reducing the capacity.

◆ reduce_capacity() [2/2]

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::reduce_capacity ( const false_type &  )
inlineprivate

Specialized method for reducing the capacity.

◆ rerase() [1/2]

template<class T , class Alloc >
iterator boost::circular_buffer_space_optimized< T, Alloc >::rerase ( iterator  pos)
inline

Remove an element at the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer_space_optimized (but not an end()).

The amount of allocated memory in the internal buffer may be predictively decreased.
Postcondition
The element at the position pos is removed.
Parameters
posAn iterator pointing at the element to be removed.
Returns
Iterator to the first element remaining in front of the removed element or begin() if no such element exists.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
Note
Basically there is no difference between erase(iterator) and this method. It is implemented only for consistency with the base circular_buffer.
See also
erase(iterator), erase(iterator, iterator), rerase(iterator, iterator), clear()

◆ rerase() [2/2]

template<class T , class Alloc >
iterator boost::circular_buffer_space_optimized< T, Alloc >::rerase ( iterator  first,
iterator  last 
)
inline

Erase the range [first, last).

Precondition
Valid range [first, last).
Postcondition
The elements from the range [first, last) are removed. (If first == last nothing is removed.)

The amount of allocated memory in the internal buffer may be predictively decreased.
Parameters
firstThe beginning of the range to be removed.
lastThe end of the range to be removed.
Returns
Iterator to the first element remaining in front of the removed elements or begin() if no such element exists.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
Note
Basically there is no difference between erase(iterator, iterator) and this method. It is implemented only for consistency with the base circular_buffer.
See also
erase(iterator), erase(iterator, iterator), rerase(iterator), clear()

◆ reserve()

template<class T , class Alloc >
size_type boost::circular_buffer_space_optimized< T, Alloc >::reserve ( ) const
inline

Get the maximum number of elements which can be inserted into the circular_buffer_space_optimized without overwriting any of already stored elements.

Returns
capacity().capacity() - size()
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Does not invalidate any iterators.
Complexity
Constant (in the size of the circular_buffer_space_optimized).
See also
capacity(), size(), max_size()

◆ resize()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::resize ( size_type  new_size,
param_value_type  item = value_type() 
)
inline

Change the size of the circular_buffer_space_optimized.

Postcondition
size() == new_size && capacity().capacity() >= new_size

If the new size is greater than the current size, copies of item will be inserted at the back of the of the circular_buffer_space_optimized in order to achieve the desired size. In the case the resulting size exceeds the current capacity the capacity will be set to new_size.

If the current number of elements stored in the circular_buffer_space_optimized is greater than the desired new size then number of [size() - new_size] last elements will be removed. (The capacity will remain unchanged.)

The amount of allocated memory in the internal buffer may be accommodated as necessary.
Parameters
new_sizeThe new size.
itemThe element the circular_buffer_space_optimized will be filled with in order to gain the requested size. (See the Effect.)
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the new size of the circular_buffer_space_optimized).
See also
rresize(size_type, const_reference), set_capacity(const capacity_type&)

◆ rinsert() [1/5]

template<class T , class Alloc >
iterator boost::circular_buffer_space_optimized< T, Alloc >::rinsert ( iterator  pos,
param_value_type  item = value_type() 
)
inline

Insert an element before the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer_space_optimized or its end.
Postcondition
The item will be inserted before the position pos.
If the circular_buffer_space_optimized is full, the last element will be overwritten. If the circular_buffer_space_optimized is full and the pos points to end(), then the item will not be inserted. If the capacity is 0, nothing will be inserted.

The amount of allocated memory in the internal buffer may be predictively increased.
Parameters
posAn iterator specifying the position before which the item will be inserted.
itemThe element to be inserted.
Returns
Iterator to the inserted element or end() if the item is not inserted. (See the Effect.)
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the size of the circular_buffer_space_optimized).
See also
rinsert(iterator, size_type, value_type), rinsert(iterator, InputIterator, InputIterator), insert(iterator, value_type), insert(iterator, size_type, value_type), insert(iterator, InputIterator, InputIterator)

◆ rinsert() [2/5]

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::rinsert ( iterator  pos,
size_type  n,
param_value_type  item 
)
inline

Insert n copies of the item before the specified position.

Precondition
pos is a valid iterator pointing to the circular_buffer_space_optimized or its end.
Postcondition
The number of min[n, (end() - pos) + reserve()] elements will be inserted before the position pos.
The number of min[end() - pos, max[0, n - reserve()]] elements will be overwritten at the end of the circular_buffer_space_optimized.
(See Example for the explanation.)

The amount of allocated memory in the internal buffer may be predictively increased.
Parameters
posAn iterator specifying the position where the items will be inserted.
nThe number of items the to be inserted.
itemThe element whose copies will be inserted.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in min[capacity().capacity(), size() + n]).
Example
Consider a circular_buffer_space_optimized with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.

|1|2|3|4| | |
p —^

After inserting 5 elements before the position p:

rinsert(p, (size_t)5, 0);

actually only 4 elements get inserted and elements 3 and 4 are overwritten. This is due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks like this:

|1|2|0|0|0|0|

For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|0|0|0|0|0|3|4|.
See also
rinsert(iterator, value_type), rinsert(iterator, InputIterator, InputIterator), insert(iterator, value_type), insert(iterator, size_type, value_type), insert(iterator, InputIterator, InputIterator)

◆ rinsert() [3/5]

template<class T , class Alloc >
template<class InputIterator >
void boost::circular_buffer_space_optimized< T, Alloc >::rinsert ( iterator  pos,
InputIterator  first,
InputIterator  last 
)
inline

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

Precondition
pos is a valid iterator pointing to the circular_buffer_space_optimized or its end.
Valid range [first, last) where first and last meet the requirements of an InputIterator.
Postcondition
Elements from the range [first, last - max[0, distance(first, last) - (end() - pos) - reserve()]) will be inserted before the position pos.
The number of min[end() - pos, max[0, distance(first, last) - reserve()]] elements will be overwritten at the end of the circular_buffer.
(See Example for the explanation.)

The amount of allocated memory in the internal buffer may be predictively increased.
Parameters
posAn iterator specifying the position where the range will be inserted.
firstThe beginning of the range to be inserted.
lastThe end of the range to be inserted.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
WhateverT::operator = (const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in [size() + std::distance(first, last)]; in min[capacity().capacity(), size() + std::distance(first, last)] if the InputIterator is a RandomAccessIterator).
Example
Consider a circular_buffer_space_optimized with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.

|1|2|3|4| | |
p —^

After inserting a range of elements before the position p:

int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);

actually only elements 5, 6, 7 and 8 from the specified range get inserted and elements 3 and 4 are overwritten. This is due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks like this:

|1|2|5|6|7|8|

For comparison if the capacity would not be preserved the internal buffer would then result in |1|2|5|6|7|8|9|3|4|.
See also
rinsert(iterator, value_type), rinsert(iterator, size_type, value_type), insert(iterator, value_type), insert(iterator, size_type, value_type), insert(iterator, InputIterator, InputIterator)

◆ rinsert() [4/5]

template<class T , class Alloc >
template<class IntegralType >
void boost::circular_buffer_space_optimized< T, Alloc >::rinsert ( const iterator pos,
IntegralType  n,
IntegralType  item,
const true_type &   
)
inlineprivate

Specialized rinsert method.

◆ rinsert() [5/5]

template<class T , class Alloc >
template<class Iterator >
void boost::circular_buffer_space_optimized< T, Alloc >::rinsert ( const iterator pos,
Iterator  first,
Iterator  last,
const false_type &   
)
inlineprivate

Specialized rinsert method.

◆ rresize()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::rresize ( size_type  new_size,
param_value_type  item = value_type() 
)
inline

Change the size of the circular_buffer_space_optimized.

Postcondition
size() == new_size && capacity().capacity() >= new_size

If the new size is greater than the current size, copies of item will be inserted at the front of the of the circular_buffer_space_optimized in order to achieve the desired size. In the case the resulting size exceeds the current capacity the capacity will be set to new_size.

If the current number of elements stored in the circular_buffer_space_optimized is greater than the desired new size then number of [size() - new_size] first elements will be removed. (The capacity will remain unchanged.)

The amount of allocated memory in the internal buffer may be accommodated as necessary.
Parameters
new_sizeThe new size.
itemThe element the circular_buffer_space_optimized will be filled with in order to gain the requested size. (See the Effect.)
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Basic.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in the new size of the circular_buffer_space_optimized).
See also
resize(size_type, const_reference), rset_capacity(const capacity_type&)

◆ rset_capacity()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::rset_capacity ( const capacity_type capacity_ctrl)
inline

Change the capacity (and the minimal guaranteed amount of allocated memory) of the circular_buffer_space_optimized.

Postcondition
capacity() == capacity_ctrl && size() <= capacity_ctrl

If the current number of elements stored in the circular_buffer_space_optimized is greater than the desired new capacity then number of [size() - capacity_ctrl.capacity()] first elements will be removed and the new size will be equal to capacity_ctrl.capacity().

If the current number of elements stored in the circular_buffer_space_optimized is lower than the new capacity then the amount of allocated memory in the internal buffer may be accommodated as necessary but it will never drop below capacity_ctrl.min_capacity().
Parameters
capacity_ctrlThe new capacity controller.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Strong.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in min[size(), capacity_ctrl.capacity()]).
See also
set_capacity(const capacity_type&), rresize(size_type, const_reference)

◆ set_capacity()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::set_capacity ( const capacity_type capacity_ctrl)
inline

Change the capacity (and the minimal guaranteed amount of allocated memory) of the circular_buffer_space_optimized.

Postcondition
capacity() == capacity_ctrl && size() <= capacity_ctrl.capacity()

If the current number of elements stored in the circular_buffer_space_optimized is greater than the desired new capacity then number of [size() - capacity_ctrl.capacity()] last elements will be removed and the new size will be equal to capacity_ctrl.capacity().

If the current number of elements stored in the circular_buffer_space_optimized is lower than the new capacity then the amount of allocated memory in the internal buffer may be accommodated as necessary but it will never drop below capacity_ctrl.min_capacity().
Parameters
capacity_ctrlThe new capacity controller.
Exceptions
An allocation errorif memory is exhausted (std::bad_alloc if the standard allocator is used).
WhateverT::T(const T&) throws.
Exception Safety
Strong.
Iterator Invalidation
Invalidates all iterators pointing to the circular_buffer_space_optimized (except iterators equal to end()).
Complexity
Linear (in min[size(), capacity_ctrl.capacity()]).
Note
To explicitly clear the extra allocated memory use the shrink-to-fit technique:

boost::circular_buffer_space_optimized<int> cb(1000);
...
boost::circular_buffer_space_optimized<int>(cb).swap(cb);


For more information about the shrink-to-fit technique in STL see http://www.gotw.ca/gotw/054.htm.
See also
rset_capacity(const capacity_type&), resize(size_type, const_reference)

◆ swap()

template<class T , class Alloc >
void boost::circular_buffer_space_optimized< T, Alloc >::swap ( circular_buffer_space_optimized< T, Alloc > &  cb)
inline

Swap the contents of two space optimized circular buffers.

Postcondition
this contains elements of cb and vice versa; the capacity and the amount of allocated memory in the internal buffer of this equal to the capacity and the amount of allocated memory of cb and vice versa.
Parameters
cbThe circular_buffer_space_optimized whose content will be swapped.
Exceptions
Nothing.
Exception Safety
No-throw.
Iterator Invalidation
Invalidates all iterators of both circular_buffer_space_optimized containers. (On the other hand the iterators still point to the same elements but within another container. If you want to rely on this feature you have to turn the Debug Support off otherwise an assertion will report an error if such invalidated iterator is used.)
Complexity
Constant (in the size of the circular_buffer_space_optimized).
See also
swap(circular_buffer_space_optimized<T, Alloc>&, circular_buffer_space_optimized<T, Alloc>&)

Member Data Documentation

◆ m_capacity_ctrl

template<class T , class Alloc >
capacity_type boost::circular_buffer_space_optimized< T, Alloc >::m_capacity_ctrl
private

The capacity controller of the space optimized circular buffer.


The documentation for this class was generated from the following file: