Circular buffer - a STL compliant container. More...
#include <base.hpp>
Public Types | |
typedef circular_buffer< T, Alloc > | this_type |
The type of this circular_buffer . More... | |
typedef boost::container::allocator_traits < Alloc >::value_type | value_type |
The type of elements stored in the circular_buffer . More... | |
typedef boost::container::allocator_traits < Alloc >::pointer | pointer |
A pointer to an element. More... | |
typedef boost::container::allocator_traits < Alloc >::const_pointer | const_pointer |
A const pointer to the element. More... | |
typedef boost::container::allocator_traits < Alloc >::reference | reference |
A reference to an element. More... | |
typedef boost::container::allocator_traits < Alloc >::const_reference | const_reference |
A const reference to an element. More... | |
typedef boost::container::allocator_traits < Alloc >::difference_type | difference_type |
The distance type. More... | |
typedef boost::container::allocator_traits < 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 < boost::container::allocator_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 < boost::container::allocator_traits < Alloc > > > | iterator |
A (random access) iterator used to iterate through the circular_buffer . More... | |
typedef boost::reverse_iterator < const_iterator > | const_reverse_iterator |
A const iterator used to iterate backwards through a circular_buffer . More... | |
typedef boost::reverse_iterator < iterator > | reverse_iterator |
An iterator used to iterate backwards through a circular_buffer . More... | |
typedef std::pair< pointer, size_type > | array_range |
An array range. More... | |
typedef std::pair < const_pointer, size_type > | const_array_range |
A range of a const array. More... | |
typedef size_type | capacity_type |
The capacity type. More... | |
typedef const value_type & | param_value_type |
A type representing the "best" way to pass the value_type to a method. More... | |
Public Member Functions | |
typedef | BOOST_RV_REF (value_type) rvalue_type |
A type representing rvalue from param type. More... | |
allocator_type | get_allocator () const BOOST_NOEXCEPT |
Get the allocator. More... | |
allocator_type & | get_allocator () BOOST_NOEXCEPT |
Get the allocator reference. More... | |
iterator | begin () BOOST_NOEXCEPT |
Get the iterator pointing to the beginning of the circular_buffer . More... | |
iterator | end () BOOST_NOEXCEPT |
Get the iterator pointing to the end of the circular_buffer . More... | |
const_iterator | begin () const BOOST_NOEXCEPT |
Get the const iterator pointing to the beginning of the circular_buffer . More... | |
const_iterator | end () const BOOST_NOEXCEPT |
Get the const iterator pointing to the end of the circular_buffer . More... | |
reverse_iterator | rbegin () BOOST_NOEXCEPT |
Get the iterator pointing to the beginning of the "reversed" circular_buffer . More... | |
reverse_iterator | rend () BOOST_NOEXCEPT |
Get the iterator pointing to the end of the "reversed" circular_buffer . More... | |
const_reverse_iterator | rbegin () const BOOST_NOEXCEPT |
Get the const iterator pointing to the beginning of the "reversed" circular_buffer . More... | |
const_reverse_iterator | rend () const BOOST_NOEXCEPT |
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... | |
const_reference | 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... | |
const_reference | 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... | |
const_reference | front () const |
Get the first element. More... | |
const_reference | 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... | |
bool | is_linearized () const BOOST_NOEXCEPT |
Is the circular_buffer linearized? More... | |
void | rotate (const_iterator new_begin) |
Rotate elements in the circular_buffer . More... | |
size_type | size () const BOOST_NOEXCEPT |
Get the number of elements currently stored in the circular_buffer . More... | |
size_type | max_size () const BOOST_NOEXCEPT |
Get the largest possible size or capacity of the circular_buffer . More... | |
bool | empty () const BOOST_NOEXCEPT |
Is the circular_buffer empty? More... | |
bool | full () const BOOST_NOEXCEPT |
Is the circular_buffer full? More... | |
size_type | reserve () const BOOST_NOEXCEPT |
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 BOOST_NOEXCEPT |
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()) BOOST_NOEXCEPT | |
Create an empty circular_buffer with zero capacity. More... | |
circular_buffer (capacity_type buffer_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 buffer_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... | |
circular_buffer (circular_buffer< T, Alloc > &&cb) BOOST_NOEXCEPT | |
The move 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 buffer_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 () BOOST_NOEXCEPT | |
The destructor. More... | |
circular_buffer< T, Alloc > & | operator= (const circular_buffer< T, Alloc > &cb) |
The assign operator. More... | |
circular_buffer< T, Alloc > & | operator= (circular_buffer< T, Alloc > &&cb) BOOST_NOEXCEPT |
Move assigns content of cb to *this , leaving cb empty. More... | |
void | assign (size_type n, param_value_type item) |
Assign n items into the circular_buffer . More... | |
void | assign (capacity_type buffer_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 buffer_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) BOOST_NOEXCEPT |
Swap the contents of two circular_buffer s. More... | |
void | push_back (param_value_type item) |
Insert a new element at the end of the circular_buffer . More... | |
void | push_back (rvalue_type item) |
Insert a new element at the end of the circular_buffer using rvalue references or rvalues references emulation. More... | |
void | push_back () |
Insert a new default-constructed element at the end of the circular_buffer . More... | |
void | push_front (param_value_type item) |
Insert a new element at the beginning of the circular_buffer . More... | |
void | push_front (rvalue_type item) |
Insert a new element at the beginning of the circular_buffer using rvalue references or rvalues references emulation. More... | |
void | push_front () |
Insert a new default-constructed 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) |
Insert an element at the specified position. More... | |
iterator | insert (iterator pos, rvalue_type item) |
Insert an element at the specified position. More... | |
iterator | insert (iterator pos) |
Insert a default-constructed 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) |
Insert an element before the specified position. More... | |
iterator | rinsert (iterator pos, rvalue_type item) |
Insert an element before the specified position. More... | |
iterator | rinsert (iterator pos) |
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 | erase_begin (size_type n) |
Remove first n elements (with constant complexity for scalar types). More... | |
void | erase_end (size_type n) |
Remove last n elements (with constant complexity for scalar types). More... | |
void | clear () BOOST_NOEXCEPT |
Remove all stored elements from the circular_buffer . More... | |
Friends | |
template<class Buff , class Traits > | |
struct | cb_details::iterator |
Circular buffer - a STL compliant container.
T | The type of the elements stored in the circular_buffer . |
T
has to be SGIAssignable (SGI STL defined combination of Assignable and CopyConstructible). Moreover T
has to be DefaultConstructible if supplied as a default parameter when invoking some of the circular_buffer
's methods e.g. insert(iterator pos, const value_type& item = value_type())
. And EqualityComparable and/or LessThanComparable if the circular_buffer
will be compared with another container. Alloc | The allocator type used for all internal memory management. |
Alloc
has to meet the allocator requirements imposed by STL. For detailed documentation of the circular_buffer visit: http://www.boost.org/libs/circular_buffer/doc/circular_buffer.html
typedef Alloc boost::circular_buffer< T, Alloc >::allocator_type |
The type of an allocator used in the circular_buffer
.
typedef std::pair<pointer, size_type> boost::circular_buffer< T, Alloc >::array_range |
An array range.
(A typedef for the std::pair
where its first element is a pointer to a beginning of an array and its second element represents a size of the array.)
typedef size_type boost::circular_buffer< T, Alloc >::capacity_type |
The capacity type.
(Same as size_type
- defined for consistency with the __cbso class.
typedef std::pair<const_pointer, size_type> boost::circular_buffer< T, Alloc >::const_array_range |
A range of a const array.
(A typedef for the std::pair
where its first element is a pointer to a beginning of a const array and its second element represents a size of the const array.)
typedef cb_details::iterator< circular_buffer<T, Alloc>, cb_details::const_traits<boost::container::allocator_traits<Alloc> > > boost::circular_buffer< T, Alloc >::const_iterator |
A const (random access) iterator used to iterate through the circular_buffer
.
typedef boost::container::allocator_traits<Alloc>::const_pointer boost::circular_buffer< T, Alloc >::const_pointer |
A const pointer to the element.
typedef boost::container::allocator_traits<Alloc>::const_reference boost::circular_buffer< T, Alloc >::const_reference |
A const reference to an element.
typedef boost::reverse_iterator<const_iterator> boost::circular_buffer< T, Alloc >::const_reverse_iterator |
A const iterator used to iterate backwards through a circular_buffer
.
typedef boost::container::allocator_traits<Alloc>::difference_type boost::circular_buffer< T, Alloc >::difference_type |
The distance type.
(A signed integral type used to represent the distance between two iterators.)
typedef cb_details::iterator< circular_buffer<T, Alloc>, cb_details::nonconst_traits<boost::container::allocator_traits<Alloc> > > boost::circular_buffer< T, Alloc >::iterator |
A (random access) iterator used to iterate through the circular_buffer
.
typedef const value_type& boost::circular_buffer< T, Alloc >::param_value_type |
A type representing the "best" way to pass the value_type to a method.
typedef boost::container::allocator_traits<Alloc>::pointer boost::circular_buffer< T, Alloc >::pointer |
A pointer to an element.
typedef boost::container::allocator_traits<Alloc>::reference boost::circular_buffer< T, Alloc >::reference |
A reference to an element.
typedef boost::reverse_iterator<iterator> boost::circular_buffer< T, Alloc >::reverse_iterator |
An iterator used to iterate backwards through a circular_buffer
.
typedef boost::container::allocator_traits<Alloc>::size_type boost::circular_buffer< T, Alloc >::size_type |
The size type.
(An unsigned integral type that can represent any non-negative value of the container's distance type.)
typedef circular_buffer<T, Alloc> boost::circular_buffer< T, Alloc >::this_type |
The type of this circular_buffer
.
typedef boost::container::allocator_traits<Alloc>::value_type boost::circular_buffer< T, Alloc >::value_type |
The type of elements stored in the circular_buffer
.
|
inlineexplicit |
Create an empty circular_buffer
with zero capacity.
capacity() == 0 && size() == 0
alloc | The allocator. |
Nothing. |
circular_buffer
with zero capacity (e.g. by push_back(const_reference)
or insert(iterator, value_type)
) nothing will be inserted and the size (as well as capacity) remains zero. set_capacity(capacity_type)
method or you can use the other constructor with the capacity specified.
|
inlineexplicit |
Create an empty circular_buffer
with the specified capacity.
capacity() == buffer_capacity && size() == 0
buffer_capacity | The maximum number of elements which can be stored in the circular_buffer . |
alloc | The allocator. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). |
|
inline |
Create a full circular_buffer
with the specified capacity and filled with n
copies of item
.
capacity() == n && full() && (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] == item
n | The number of elements the created circular_buffer will be filled with. |
item | The element the created circular_buffer will be filled with. |
alloc | The allocator. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
n
).
|
inline |
Create a circular_buffer
with the specified capacity and filled with n
copies of item
.
buffer_capacity >= n
capacity() == buffer_capacity && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] == item
buffer_capacity | The capacity of the created circular_buffer . |
n | The number of elements the created circular_buffer will be filled with. |
item | The element the created circular_buffer will be filled with. |
alloc | The allocator. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
n
).
|
inline |
The copy constructor.
Creates a copy of the specified circular_buffer
.
*this == cb
cb | The circular_buffer to be copied. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
cb
).
|
inline |
The move constructor.
Move constructs a circular_buffer
from cb
, leaving cb
empty.
cb.empty()
cb | circular_buffer to 'steal' value from. |
Nothing. |
|
inline |
Create a full circular_buffer
filled with a copy of the range.
[first, last)
.first
and last
have to meet the requirements of InputIterator. capacity() == std::distance(first, last) && full() && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... && (*this)[std::distance(first, last) - 1] == *(last - 1)
first | The beginning of the range to be copied. |
last | The end of the range to be copied. |
alloc | The allocator. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
std::distance(first, last)
).
|
inline |
Create a circular_buffer
with the specified capacity and filled with a copy of the range.
[first, last)
.first
and last
have to meet the requirements of InputIterator. capacity() == buffer_capacity && size() <= std::distance(first, last) && (*this)[0]== *(last - buffer_capacity) && (*this)[1] == *(last - buffer_capacity + 1) && ... && (*this)[buffer_capacity - 1] == *(last - 1)
[first, last)
is greater than the specified buffer_capacity
then only elements from the range [last - buffer_capacity, last)
will be copied. buffer_capacity | The capacity of the created circular_buffer . |
first | The beginning of the range to be copied. |
last | The end of the range to be copied. |
alloc | The allocator. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
std::distance(first, last)
; in min[capacity, std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator).
|
inline |
The destructor.
Destroys the circular_buffer
.
Nothing. |
circular_buffer
(including iterators equal to end()
). circular_buffer
) for scalar types; linear for other types. clear()
|
inline |
Get the first continuous array of the internal buffer.
This method in combination with array_two()
can be useful when passing the stored data into a legacy C API as an array. Suppose there is a circular_buffer
of capacity 10, containing 7 characters 'a', 'b', ..., 'g'
where buff[0] == 'a'
, buff[1] == 'b'
, ... and buff[6] == 'g'
:
circular_buffer<char> buff(10);
The internal representation is often not linear and the state of the internal buffer may look like this:
|e|f|g| | | |a|b|c|d|
end ___^
begin _______^
where |a|b|c|d|
represents the "array one", |e|f|g|
represents the "array two" and | | | |
is a free space.
Now consider a typical C style function for writing data into a file:
int write(int file_desc, char* buff, int num_bytes);
There are two ways how to write the content of the circular_buffer
into a file. Either relying on array_one()
and array_two()
methods and calling the write function twice:
array_range ar = buff.array_one();
write(file_desc, ar.first, ar.second);
ar = buff.array_two();
write(file_desc, ar.first, ar.second);
Or relying on the linearize()
method:
write(file_desc, buff.linearize(), buff.size());
Since the complexity of array_one()
and array_two()
methods is constant the first option is suitable when calling the write method is "cheap". On the other hand the second option is more suitable when calling the write method is more "expensive" than calling the linearize()
method whose complexity is linear.
circular_buffer
is empty the size of the returned array is 0
. Nothing. |
circular_buffer
). array_one()
and array_two()
(and their const versions). |a|b|c|d|e|f|g| | | |
the "array one" is represented by |a|b|c|d|e|f|g|
and the "array two" does not exist (the array_two()
method returns an array with the size 0
). array_two()
, linearize()
|
inline |
Get the first continuous array of the internal buffer.
This method in combination with array_two() const
can be useful when passing the stored data into a legacy C API as an array.
circular_buffer
is empty the size of the returned array is 0
. Nothing. |
circular_buffer
). array_two() const
; array_one()
for more details how to pass data into a legacy C API.
|
inline |
Get the second continuous array of the internal buffer.
This method in combination with array_one()
can be useful when passing the stored data into a legacy C API as an array.
circular_buffer
is empty the size of the returned array is 0
. Nothing. |
circular_buffer
). array_one()
|
inline |
Get the second continuous array of the internal buffer.
This method in combination with array_one() const
can be useful when passing the stored data into a legacy C API as an array.
circular_buffer
is empty the size of the returned array is 0
. Nothing. |
circular_buffer
). array_one() const
|
inline |
Assign n
items into the circular_buffer
.
The content of the circular_buffer
will be removed and replaced with n
copies of the item
.
capacity() == n && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] == item
n | The number of elements the circular_buffer will be filled with. |
item | The element the circular_buffer will be filled with. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer
(except iterators equal to end()
). n
). operator=
, assign(capacity_type, size_type, const_reference)
, assign(InputIterator, InputIterator)
, assign(capacity_type, InputIterator, InputIterator)
Referenced by boost::circular_buffer_space_optimized< T, Alloc >::assign(), boost::circular_buffer< Sample >::assign(), and boost::circular_buffer_space_optimized< T, Alloc >::operator=().
|
inline |
Assign n
items into the circular_buffer
specifying the capacity.
The capacity of the circular_buffer
will be set to the specified value and the content of the circular_buffer
will be removed and replaced with n
copies of the item
.
capacity >= n
capacity() == buffer_capacity && size() == n && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] == item
buffer_capacity | The new capacity. |
n | The number of elements the circular_buffer will be filled with. |
item | The element the circular_buffer will be filled with. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer
(except iterators equal to end()
). n
).
|
inline |
Assign a copy of the range into the circular_buffer
.
The content of the circular_buffer
will be removed and replaced with copies of elements from the specified range.
[first, last)
.first
and last
have to meet the requirements of InputIterator. capacity() == std::distance(first, last) && size() == std::distance(first, last) && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... && (*this)[std::distance(first, last) - 1] == *(last - 1)
first | The beginning of the range to be copied. |
last | The end of the range to be copied. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer
(except iterators equal to end()
). std::distance(first, last)
).
|
inline |
Assign a copy of the range into the circular_buffer
specifying the capacity.
The capacity of the circular_buffer
will be set to the specified value and the content of the circular_buffer
will be removed and replaced with copies of elements from the specified range.
[first, last)
.first
and last
have to meet the requirements of InputIterator. capacity() == buffer_capacity && size() <= std::distance(first, last) && (*this)[0]== *(last - buffer_capacity) && (*this)[1] == *(last - buffer_capacity + 1) && ... && (*this)[buffer_capacity - 1] == *(last - 1)
[first, last)
is greater than the specified buffer_capacity
then only elements from the range [last - buffer_capacity, last)
will be copied. buffer_capacity | The new capacity. |
first | The beginning of the range to be copied. |
last | The end of the range to be copied. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer
(except iterators equal to end()
). std::distance(first, last)
; in min[capacity, std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator).
|
inline |
Get the element at the index
position.
index | The position of the element. |
index
position. <code>std::out_of_range</code> | when the index is invalid (when index >= size() ). |
circular_buffer
). operator[]
|
inline |
Get the element at the index
position.
index | The position of the element. |
index
position. <code>std::out_of_range</code> | when the index is invalid (when index >= size() ). |
circular_buffer
). operator[] const
|
inline |
Get the last element.
!empty()
circular_buffer
. Nothing. |
circular_buffer
). front()
Referenced by boost::circular_buffer< Sample >::rotate().
|
inline |
Get the last element.
!empty()
circular_buffer
. Nothing. |
circular_buffer
). front() const
|
inline |
Get the iterator pointing to the beginning of the circular_buffer
.
circular_buffer
. If the circular_buffer
is empty it returns an iterator equal to the one returned by end()
. Nothing. |
circular_buffer
). Referenced by boost::circular_buffer< Sample >::circular_buffer(), boost::circular_buffer_space_optimized< T, Alloc >::clear(), boost::circular_buffer_space_optimized< T, Alloc >::erase(), boost::circular_buffer_space_optimized< T, Alloc >::insert(), boost::circular_buffer_space_optimized< T, Alloc >::operator=(), boost::circular_buffer< Sample >::operator=(), boost::operator==(), boost::circular_buffer< Sample >::rend(), boost::circular_buffer_space_optimized< T, Alloc >::rerase(), boost::circular_buffer< Sample >::rerase(), boost::circular_buffer_space_optimized< T, Alloc >::rinsert(), boost::circular_buffer< Sample >::rotate(), boost::circular_buffer_space_optimized< T, Alloc >::rresize(), boost::circular_buffer< Sample >::rresize(), boost::circular_buffer_space_optimized< T, Alloc >::rset_capacity(), and boost::circular_buffer< Sample >::set_capacity().
|
inline |
Get the const iterator pointing to the beginning of the circular_buffer
.
circular_buffer
. If the circular_buffer
is empty it returns an iterator equal to the one returned by end() const
. Nothing. |
circular_buffer
). end() const
, rbegin() const
, rend() const
typedef boost::circular_buffer< T, Alloc >::BOOST_RV_REF | ( | value_type | ) |
A type representing rvalue from param type.
On compilers without rvalue references support this type is the Boost.Moves type used for emulation.
|
inline |
Get the capacity of the circular_buffer
.
circular_buffer
. Nothing. |
circular_buffer
). reserve()
, size()
, max_size()
, set_capacity(capacity_type)
Referenced by boost::circular_buffer< Sample >::circular_buffer(), boost::circular_buffer< Sample >::full(), boost::circular_buffer< Sample >::insert(), boost::accumulators::impl::rolling_window_plus1_impl< Sample >::operator=(), boost::circular_buffer< Sample >::operator=(), boost::circular_buffer< Sample >::reserve(), boost::circular_buffer< Sample >::resize(), boost::accumulators::impl::rolling_window_plus1_impl< Sample >::rolling_window_plus1_impl(), boost::circular_buffer< Sample >::rresize(), boost::circular_buffer< Sample >::rset_capacity(), and boost::circular_buffer< Sample >::set_capacity().
|
inline |
Remove all stored elements from the circular_buffer
.
size() == 0
Nothing. |
circular_buffer
(except iterators equal to end()
). circular_buffer
) for scalar types; linear for other types.
|
inline |
Is the circular_buffer
empty?
true
if there are no elements stored in the circular_buffer
; false
otherwise. Nothing. |
circular_buffer
). full()
Referenced by boost::circular_buffer< Sample >::array_one(), boost::circular_buffer< Sample >::array_two(), boost::circular_buffer< Sample >::back(), boost::circular_buffer< Sample >::begin(), boost::circular_buffer< Sample >::front(), boost::circular_buffer< Sample >::linearize(), boost::circular_buffer< Sample >::pop_back(), and boost::circular_buffer< Sample >::pop_front().
|
inline |
Get the iterator pointing to the end of the circular_buffer
.
circular_buffer
. If the circular_buffer
is empty it returns an iterator equal to the one returned by begin()
. Nothing. |
circular_buffer
). Referenced by boost::circular_buffer< Sample >::circular_buffer(), boost::circular_buffer_space_optimized< T, Alloc >::clear(), boost::circular_buffer< Sample >::erase(), boost::circular_buffer< Sample >::insert(), boost::circular_buffer< Sample >::linearize(), boost::circular_buffer_space_optimized< T, Alloc >::operator=(), boost::circular_buffer< Sample >::operator=(), boost::operator==(), boost::circular_buffer< Sample >::rbegin(), boost::circular_buffer_space_optimized< T, Alloc >::resize(), boost::circular_buffer< Sample >::resize(), boost::circular_buffer< Sample >::rotate(), boost::circular_buffer_space_optimized< T, Alloc >::rresize(), boost::circular_buffer< Sample >::rresize(), boost::circular_buffer< Sample >::rset_capacity(), and boost::circular_buffer_space_optimized< T, Alloc >::set_capacity().
|
inline |
Get the const iterator pointing to the end of the circular_buffer
.
circular_buffer
. If the circular_buffer
is empty it returns an iterator equal to the one returned by begin() const
const. Nothing. |
circular_buffer
). begin() const
, rbegin() const
, rend() const
|
inline |
Remove an element at the specified position.
pos
is a valid iterator pointing to the circular_buffer
(but not an end()
). pos
is removed. pos | An iterator pointing at the element to be removed. |
end()
if no such element exists. <a | href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
end()
). std::distance(pos, end())
). erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, erase_end(size_type)
, clear()
Referenced by boost::circular_buffer_space_optimized< T, Alloc >::erase(), boost::circular_buffer< Sample >::resize(), and boost::circular_buffer_space_optimized< T, Alloc >::set_capacity().
|
inline |
Erase the range [first, last)
.
[first, last)
. [first, last)
are removed. (If first == last
nothing is removed.) first | The beginning of the range to be removed. |
last | The end of the range to be removed. |
end()
if no such element exists. <a | href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
end()
). std::distance(first, end())
).
|
inline |
Remove first n
elements (with constant complexity for scalar types).
n <= size()
n
elements at the beginning of the circular_buffer
will be removed. n | The number of elements to be removed. |
<a | href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
n
erased elements. n
) for scalar types; linear for other types. rerase(begin(), begin() + n)
. erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_end(size_type)
, clear()
Referenced by boost::circular_buffer< Sample >::erase_begin().
|
inline |
Remove last n
elements (with constant complexity for scalar types).
n <= size()
n
elements at the end of the circular_buffer
will be removed. n | The number of elements to be removed. |
<a | href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
n
erased elements. n
) for scalar types; linear for other types. erase(end() - n, end())
. erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, clear()
Referenced by boost::circular_buffer< Sample >::erase_end().
|
inline |
Get the first element.
!empty()
circular_buffer
. Nothing. |
circular_buffer
). back()
Referenced by boost::circular_buffer< Sample >::rotate().
|
inline |
Get the first element.
!empty()
circular_buffer
. Nothing. |
circular_buffer
). back() const
|
inline |
Is the circular_buffer
full?
true
if the number of elements stored in the circular_buffer
equals the capacity of the circular_buffer
; false
otherwise. Nothing. |
circular_buffer
). empty()
Referenced by boost::circular_buffer< Sample >::rotate().
|
inline |
Get the allocator.
Nothing. |
circular_buffer
). get_allocator()
for obtaining an allocator reference. Referenced by boost::circular_buffer_space_optimized< T, Alloc >::operator=(), and boost::circular_buffer< Sample >::operator=().
|
inline |
Get the allocator reference.
Nothing. |
circular_buffer
). get_allocator() const
|
inline |
Insert an element at the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end. item
will be inserted at the position pos
.circular_buffer
is full, the first element will be overwritten. If the circular_buffer
is full and the pos
points to begin()
, then the item
will not be inserted. If the capacity is 0
, nothing will be inserted. pos | An iterator specifying the position where the item will be inserted. |
item | The element to be inserted. |
begin()
if the item
is not inserted. (See the Effect.) Whatever | T::T(const T&) throws. Whatever T::operator = (const T&) throws. Exceptions of move_if_noexcept(T&). |
pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten element. std::distance(pos, end())
). insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
, rinsert(iterator, value_type)
, rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
Referenced by boost::circular_buffer_space_optimized< T, Alloc >::insert(), boost::circular_buffer< Sample >::insert(), and boost::circular_buffer< Sample >::resize().
|
inline |
Insert an element at the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end. item
will be inserted at the position pos
.circular_buffer
is full, the first element will be overwritten. If the circular_buffer
is full and the pos
points to begin()
, then the item
will not be inserted. If the capacity is 0
, nothing will be inserted. pos | An iterator specifying the position where the item will be inserted. |
item | The element to be inserted. |
begin()
if the item
is not inserted. (See the Effect.) Whatever | T::T(T&&) throws. Whatever T::operator = (T&&) throws. Exceptions of move_if_noexcept(T&). |
pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten element. std::distance(pos, end())
).
|
inline |
Insert a default-constructed element at the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end. item
will be inserted at the position pos
.circular_buffer
is full, the first element will be overwritten. If the circular_buffer
is full and the pos
points to begin()
, then the item
will not be inserted. If the capacity is 0
, nothing will be inserted. pos | An iterator specifying the position where the item will be inserted. |
begin()
if the item
is not inserted. (See the Effect.) Whatever | T::T() throws. Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. Exceptions of move_if_noexcept(T&). |
pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten element. std::distance(pos, end())
).
|
inline |
Insert n
copies of the item
at the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end. min[n, (pos - begin()) + reserve()]
elements will be inserted at the position pos
.min[pos - begin(), max[0, n - reserve()]]
elements will be overwritten at the beginning of the circular_buffer
.pos | An iterator specifying the position where the item s will be inserted. |
n | The number of item s the to be inserted. |
item | The element whose copies will be inserted. |
Whatever | T::T(const T&) throws. Whatever T::operator = (const T&) throws. Exceptions of move_if_noexcept(T&). |
pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten elements. min[capacity(), std::distance(pos, end()) + n]
). circular_buffer
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.|1|2|3|4| | |
p ___^
p
:insert(p, (size_t)5, 0);
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|
|1|2|0|0|0|0|0|3|4|
.
|
inline |
Insert the range [first, last)
at the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end.[first, last)
where first
and last
meet the requirements of an InputIterator. [first + max[0, distance(first, last) - (pos - begin()) - reserve()], last)
will be inserted at the position pos
.min[pos - begin(), max[0, distance(first, last) - reserve()]]
elements will be overwritten at the beginning of the circular_buffer
.pos | An iterator specifying the position where the range will be inserted. |
first | The beginning of the range to be inserted. |
last | The end of the range to be inserted. |
Whatever | T::T(const T&) throws if the InputIterator is not a move iterator. Whatever T::operator = (const T&) throws if the InputIterator is not a move iterator. Whatever T::T(T&&) throws if the InputIterator is a move iterator. Whatever T::operator = (T&&) throws if the InputIterator is a move iterator. |
pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten elements. [std::distance(pos, end()) + std::distance(first, last)]
; in min[capacity(), std::distance(pos, end()) + std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator). circular_buffer
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.|1|2|3|4| | |
p ___^
p
:int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);
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|
|1|2|5|6|7|8|9|3|4|
.
|
inline |
Is the circular_buffer
linearized?
true
if the internal buffer is linearized into a continuous array (i.e. the circular_buffer
meets a condition &(*this)[0] < &(*this)[1] < ... < &(*this)[size() - 1]
); false
otherwise. Nothing. |
circular_buffer
). linearize()
, array_one()
, array_two()
|
inline |
Linearize the internal buffer into a continuous array.
This method can be useful when passing the stored data into a legacy C API as an array.
&(*this)[0] < &(*this)[1] < ... < &(*this)[size() - 1]
0
if empty. <a | href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
circular_buffer
(except iterators equal to end()
); does not invalidate any iterators if the postcondition (the Effect) is already met prior calling this method. circular_buffer
); constant if the postcondition (the Effect) is already met. circular_buffer
may delinearize the internal buffer and invalidate the returned pointer. array_one()
and array_two()
for the other option how to pass data into a legacy C API; is_linearized()
, rotate(const_iterator)
|
inline |
Get the largest possible size or capacity of the circular_buffer
.
(It depends on allocator's max_size()).
circular_buffer
can be set to. Nothing. |
circular_buffer
). size()
, capacity()
, reserve()
|
inline |
The assign operator.
Makes this circular_buffer
to become a copy of the specified circular_buffer
.
*this == cb
cb | The circular_buffer to be copied. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer
(except iterators equal to end()
). cb
).
|
inline |
Move assigns content of cb
to *this
, leaving cb
empty.
cb.empty()
cb | circular_buffer to 'steal' value from. |
Nothing. |
|
inline |
Get the element at the index
position.
0 <= index && index < size()
index | The position of the element. |
index
position. Nothing. |
circular_buffer
). at()
|
inline |
Get the element at the index
position.
0 <= index && index < size()
index | The position of the element. |
index
position. Nothing. |
circular_buffer
). at() const
|
inline |
Remove the last element from the circular_buffer
.
!empty()
circular_buffer
. Nothing. |
circular_buffer
). Referenced by boost::circular_buffer_space_optimized< T, Alloc >::pop_back(), and boost::circular_buffer< Sample >::rotate().
|
inline |
Remove the first element from the circular_buffer
.
!empty()
circular_buffer
. Nothing. |
circular_buffer
). Referenced by boost::circular_buffer_space_optimized< T, Alloc >::pop_front(), and boost::circular_buffer< Sample >::rotate().
|
inline |
Insert a new element at the end of the circular_buffer
.
capacity() > 0
then back() == item
circular_buffer
is full, the first element will be removed. If the capacity is 0
, nothing will be inserted. item | The element to be inserted. |
Whatever | T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
circular_buffer
). push_front(const_reference)
, pop_back()
, pop_front()
|
inline |
Insert a new element at the end of the circular_buffer
using rvalue references or rvalues references emulation.
capacity() > 0
then back() == item
circular_buffer
is full, the first element will be removed. If the capacity is 0
, nothing will be inserted. item | The element to be inserted. |
Whatever | T::T(T&&) throws. Whatever T::operator = (T&&) throws. |
circular_buffer
). push_front(const_reference)
, pop_back()
, pop_front()
|
inline |
Insert a new default-constructed element at the end of the circular_buffer
.
capacity() > 0
then back() == item
circular_buffer
is full, the first element will be removed. If the capacity is 0
, nothing will be inserted. Whatever | T::T() throws. Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. |
circular_buffer
). push_front(const_reference)
, pop_back()
, pop_front()
Referenced by boost::circular_buffer_space_optimized< T, Alloc >::push_back(), boost::circular_buffer< Sample >::push_back(), and boost::circular_buffer< Sample >::rotate().
|
inline |
Insert a new element at the beginning of the circular_buffer
.
capacity() > 0
then front() == item
circular_buffer
is full, the last element will be removed. If the capacity is 0
, nothing will be inserted. item | The element to be inserted. |
Whatever | T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
circular_buffer
). push_back(const_reference)
, pop_back()
, pop_front()
|
inline |
Insert a new element at the beginning of the circular_buffer
using rvalue references or rvalues references emulation.
capacity() > 0
then front() == item
circular_buffer
is full, the last element will be removed. If the capacity is 0
, nothing will be inserted. item | The element to be inserted. |
Whatever | T::T(T&&) throws. Whatever T::operator = (T&&) throws. |
circular_buffer
). push_back(const_reference)
, pop_back()
, pop_front()
|
inline |
Insert a new default-constructed element at the beginning of the circular_buffer
.
capacity() > 0
then front() == item
circular_buffer
is full, the last element will be removed. If the capacity is 0
, nothing will be inserted. Whatever | T::T() throws. Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. |
circular_buffer
). push_back(const_reference)
, pop_back()
, pop_front()
Referenced by boost::circular_buffer_space_optimized< T, Alloc >::push_front(), boost::circular_buffer< Sample >::push_front(), and boost::circular_buffer< Sample >::rotate().
|
inline |
Get the iterator pointing to the beginning of the "reversed" circular_buffer
.
circular_buffer
. If the circular_buffer
is empty it returns an iterator equal to the one returned by rend()
. Nothing. |
circular_buffer
).
|
inline |
Get the const iterator pointing to the beginning of the "reversed" circular_buffer
.
circular_buffer
. If the circular_buffer
is empty it returns an iterator equal to the one returned by rend() const
. Nothing. |
circular_buffer
). rend() const
, begin() const
, end() const
|
inline |
Get the iterator pointing to the end of the "reversed" circular_buffer
.
circular_buffer
. If the circular_buffer
is empty it returns an iterator equal to the one returned by rbegin()
. Nothing. |
circular_buffer
).
|
inline |
Get the const iterator pointing to the end of the "reversed" circular_buffer
.
circular_buffer
. If the circular_buffer
is empty it returns an iterator equal to the one returned by rbegin() const
. Nothing. |
circular_buffer
). rbegin() const
, begin() const
, end() const
|
inline |
Remove an element at the specified position.
pos
is a valid iterator pointing to the circular_buffer
(but not an end()
). pos
is removed. pos | An iterator pointing at the element to be removed. |
begin()
if no such element exists. <a | href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
std::distance(begin(), pos)
). erase(iterator)
method and is more effective than erase(iterator)
if the iterator pos
is close to the beginning of the circular_buffer
. (See the Complexity.) erase(iterator)
, erase(iterator, iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, erase_end(size_type)
, clear()
Referenced by boost::circular_buffer_space_optimized< T, Alloc >::rerase(), boost::circular_buffer< Sample >::rresize(), and boost::circular_buffer_space_optimized< T, Alloc >::rset_capacity().
|
inline |
Erase the range [first, last)
.
[first, last)
. [first, last)
are removed. (If first == last
nothing is removed.) first | The beginning of the range to be removed. |
last | The end of the range to be removed. |
begin()
if no such element exists. <a | href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
std::distance(begin(), last)
). erase(iterator, iterator)
method and is more effective than erase(iterator, iterator)
if std::distance(begin(), first)
is lower that std::distance(last, end())
.
|
inline |
Get the maximum number of elements which can be inserted into the circular_buffer
without overwriting any of already stored elements.
capacity() - size()
Nothing. |
circular_buffer
). capacity()
, size()
, max_size()
|
inline |
Change the size of the circular_buffer
.
size() == new_size && capacity() >= new_size
item
will be inserted at the back of the of the circular_buffer
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
.circular_buffer
is greater than the desired new size then number of [size() - new_size]
last elements will be removed. (The capacity will remain unchanged.) new_size | The new size. |
item | The element the circular_buffer will be filled with in order to gain the requested size. (See the Effect.) |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
circular_buffer
(except iterators equal to end()
) if the new size is greater than the current capacity. Invalidates iterators pointing to the removed elements if the new size is lower that the original size. Otherwise it does not invalidate any iterator. circular_buffer
).
|
inline |
Insert an element before the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end. item
will be inserted before the position pos
.circular_buffer
is full, the last element will be overwritten. If the circular_buffer
is full and the pos
points to end()
, then the item
will not be inserted. If the capacity is 0
, nothing will be inserted. pos | An iterator specifying the position before which the item will be inserted. |
item | The element to be inserted. |
end()
if the item
is not inserted. (See the Effect.) Whatever | T::T(const T&) throws. Whatever T::operator = (const T&) throws. Exceptions of move_if_noexcept(T&). |
pos
). It also invalidates iterators pointing to the overwritten element. std::distance(begin(), pos)
). rinsert(iterator, size_type, value_type)
, rinsert(iterator, InputIterator, InputIterator)
, insert(iterator, value_type)
, insert(iterator, size_type, value_type)
, insert(iterator, InputIterator, InputIterator)
Referenced by boost::circular_buffer_space_optimized< T, Alloc >::rinsert(), boost::circular_buffer< Sample >::rinsert(), and boost::circular_buffer< Sample >::rresize().
|
inline |
Insert an element before the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end. item
will be inserted before the position pos
.circular_buffer
is full, the last element will be overwritten. If the circular_buffer
is full and the pos
points to end()
, then the item
will not be inserted. If the capacity is 0
, nothing will be inserted. pos | An iterator specifying the position before which the item will be inserted. |
item | The element to be inserted. |
end()
if the item
is not inserted. (See the Effect.) Whatever | T::T(T&&) throws. Whatever T::operator = (T&&) throws. Exceptions of move_if_noexcept(T&). |
pos
). It also invalidates iterators pointing to the overwritten element. std::distance(begin(), pos)
).
|
inline |
Insert an element before the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end. item
will be inserted before the position pos
.circular_buffer
is full, the last element will be overwritten. If the circular_buffer
is full and the pos
points to end()
, then the item
will not be inserted. If the capacity is 0
, nothing will be inserted. pos | An iterator specifying the position before which the item will be inserted. |
end()
if the item
is not inserted. (See the Effect.) Whatever | T::T() throws. Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. Exceptions of move_if_noexcept(T&). |
pos
). It also invalidates iterators pointing to the overwritten element. std::distance(begin(), pos)
).
|
inline |
Insert n
copies of the item
before the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end. min[n, (end() - pos) + reserve()]
elements will be inserted before the position pos
.min[end() - pos, max[0, n - reserve()]]
elements will be overwritten at the end of the circular_buffer
.pos | An iterator specifying the position where the item s will be inserted. |
n | The number of item s the to be inserted. |
item | The element whose copies will be inserted. |
Whatever | T::T(const T&) throws. Whatever T::operator = (const T&) throws. Exceptions of move_if_noexcept(T&). |
pos
). It also invalidates iterators pointing to the overwritten elements. min[capacity(), std::distance(begin(), pos) + n]
). circular_buffer
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.|1|2|3|4| | |
p ___^
p
:rinsert(p, (size_t)5, 0);
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|
|1|2|0|0|0|0|0|3|4|
.
|
inline |
Insert the range [first, last)
before the specified position.
pos
is a valid iterator pointing to the circular_buffer
or its end.[first, last)
where first
and last
meet the requirements of an InputIterator. [first, last - max[0, distance(first, last) - (end() - pos) - reserve()])
will be inserted before the position pos
.min[end() - pos, max[0, distance(first, last) - reserve()]]
elements will be overwritten at the end of the circular_buffer
.pos | An iterator specifying the position where the range will be inserted. |
first | The beginning of the range to be inserted. |
last | The end of the range to be inserted. |
Whatever | T::T(const T&) throws if the InputIterator is not a move iterator. Whatever T::operator = (const T&) throws if the InputIterator is not a move iterator. Whatever T::T(T&&) throws if the InputIterator is a move iterator. Whatever T::operator = (T&&) throws if the InputIterator is a move iterator. |
pos
). It also invalidates iterators pointing to the overwritten elements. [std::distance(begin(), pos) + std::distance(first, last)]
; in min[capacity(), std::distance(begin(), pos) + std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator). circular_buffer
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.|1|2|3|4| | |
p ___^
p
:int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);
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|
|1|2|5|6|7|8|9|3|4|
.
|
inline |
Rotate elements in the circular_buffer
.
A more effective implementation of std::rotate
.
new_begin
is a valid iterator pointing to the circular_buffer
except its end. m == std::distance(new_begin, end())
n == std::distance(begin(), new_begin)
val_0 == *new_begin, val_1 == *(new_begin + 1), ... val_m == *(new_begin + m)
val_r1 == *(new_begin - 1), val_r2 == *(new_begin - 2), ... val_rn == *(new_begin - n)
val_0 == (*this)[0] && val_1 == (*this)[1] && ... && val_m == (*this)[m - 1] && val_r1 == (*this)[m + n - 1] && val_r2 == (*this)[m + n - 2] && ... && val_rn == (*this)[m]
new_begin | The new beginning. |
See | Exceptions of move_if_noexcept(T&). |
circular_buffer
is full or new_begin
points to begin()
or if the operations in the Throws section do not throw anything. m < n
invalidates iterators pointing to the last m
elements (including new_begin
, but not iterators equal to end()
) else invalidates iterators pointing to the first n
elements; does not invalidate any iterators if the circular_buffer
is full. (std::min)(m, n)
); constant if the circular_buffer
is full. std::rotate
|
inline |
Change the size of the circular_buffer
.
size() == new_size && capacity() >= new_size
item
will be inserted at the front of the of the circular_buffer
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
.circular_buffer
is greater than the desired new size then number of [size() - new_size]
first elements will be removed. (The capacity will remain unchanged.) new_size | The new size. |
item | The element the circular_buffer will be filled with in order to gain the requested size. (See the Effect.) |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
circular_buffer
(except iterators equal to end()
) if the new size is greater than the current capacity. Invalidates iterators pointing to the removed elements if the new size is lower that the original size. Otherwise it does not invalidate any iterator. circular_buffer
).
|
inline |
Change the capacity of the circular_buffer
.
T
is a move only type, then compiler shall support noexcept
modifiers and move constructor of T
must be marked with it (must not throw exceptions). capacity() == new_capacity && size() <= new_capacity
circular_buffer
is greater than the desired new capacity then number of [size() - new_capacity]
first elements will be removed and the new size will be equal to new_capacity
. new_capacity | The new capacity. |
An allocation error | if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
circular_buffer
(except iterators equal to end()
) if the new capacity is different from the original. min[size(), new_capacity]
).
|
inline |
Change the capacity of the circular_buffer
.
T
is a move only type, then compiler shall support noexcept
modifiers and move constructor of T
must be marked with it (must not throw exceptions). capacity() == new_capacity && size() <= new_capacity
circular_buffer
is greater than the desired new capacity then number of [size() - new_capacity]
last elements will be removed and the new size will be equal to new_capacity
. new_capacity | The new capacity. |
An allocation error | if memory is exhausted, (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws or nothing if T::T(T&&) is noexcept. |
circular_buffer
(except iterators equal to end()
) if the new capacity is different from the original. min[size(), new_capacity]
). Referenced by boost::accumulators::impl::rolling_window_plus1_impl< Sample >::operator=(), boost::circular_buffer< Sample >::resize(), and boost::circular_buffer< Sample >::rresize().
|
inline |
Get the number of elements currently stored in the circular_buffer
.
circular_buffer
. Nothing. |
circular_buffer
). Referenced by boost::circular_buffer< Sample >::circular_buffer(), boost::circular_buffer< Sample >::empty(), boost::circular_buffer< Sample >::erase_begin(), boost::circular_buffer< Sample >::erase_end(), boost::circular_buffer_space_optimized< T, Alloc >::full(), boost::circular_buffer< Sample >::full(), boost::circular_buffer< Sample >::linearize(), boost::operator==(), boost::circular_buffer< Sample >::operator[](), boost::circular_buffer_space_optimized< T, Alloc >::reserve(), boost::circular_buffer< Sample >::reserve(), boost::circular_buffer_space_optimized< T, Alloc >::resize(), boost::circular_buffer< Sample >::resize(), boost::circular_buffer_space_optimized< T, Alloc >::rresize(), boost::circular_buffer< Sample >::rresize(), boost::circular_buffer_space_optimized< T, Alloc >::rset_capacity(), boost::circular_buffer< Sample >::rset_capacity(), boost::circular_buffer_space_optimized< T, Alloc >::set_capacity(), and boost::circular_buffer< Sample >::set_capacity().
|
inline |
Swap the contents of two circular_buffer
s.
this
contains elements of cb
and vice versa; the capacity of this
equals to the capacity of cb
and vice versa. cb | The circular_buffer whose content will be swapped. |
Nothing. |
circular_buffer
s. (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.) circular_buffer
). Referenced by boost::circular_buffer< Sample >::operator=(), and boost::circular_buffer_space_optimized< T, Alloc >::swap().
|
friend |