![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
Class template circular_bufferBoost , The Boost C++ Libraries BoostBook Documentation Subset , Boost.Circular_buffer C++ Reference
|
![]() | Warning |
---|---|
Since Boost version 1.36 the behaviour of this constructor has changed. Now the constructor does not allocate any memory and both capacity and size are set to zero. Also note when inserting an element into a |
![]() | Note |
---|---|
You can explicitly set the capacity by calling the |
See Also:
circular_buffer(capacity_type, const allocator_type& alloc)
, set_capacity(capacity_type)
Parameters: |
| ||
Postconditions: |
| ||
Throws: | Nothing. |
explicit circular_buffer(capacity_type buffer_capacity, const allocator_type & alloc = allocator_type());Create an empty
circular_buffer
with the specified capacity.
Complexity. Constant.
Parameters: |
| ||||
Postconditions: |
| ||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). |
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
.
Complexity. Linear (in the n
).
Parameters: |
| ||||||
Postconditions: |
| ||||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
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
.
Complexity. Linear (in the n
).
Parameters: |
| ||||||||
Requires: |
| ||||||||
Postconditions: |
| ||||||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer(const circular_buffer< T, Alloc > & cb);The copy constructor.
Creates a copy of the specified
.
circular_buffer
Complexity. Linear (in the size of cb
).
Parameters: |
| ||
Postconditions: |
| ||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
circular_buffer(circular_buffer< T, Alloc > && cb) noexcept;The move constructor.
Move constructs a
from circular_buffer
cb
, leaving cb
empty.
Constant.
Parameters: |
| ||
Requires: | C++ compiler with rvalue references support. | ||
Postconditions: |
| ||
Throws: | Nothing. |
template<typename 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.
Complexity. Linear (in the std::distance(first, last)
).
Parameters: |
| ||||||
Requires: | Valid range | ||||||
Postconditions: |
| ||||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
template<typename 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.
Complexity. Linear (in std::distance(first, last)
; in min[capacity, std::distance(first, last)]
if the InputIterator
is a RandomAccessIterator).
Parameters: |
| ||||||||
Requires: | Valid range | ||||||||
Postconditions: |
| ||||||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
Сохранность восприятия. Стенок.
Удостоверение генератора. Указывает все итераторы, указывающие на этот
(за исключением итераторов, равных circular_buffer
end()
).
Сложность. Линеар (в размере cb
).
См. также:
assign(size_type, const_reference)
, assign(capacity_type, size_type, const_reference)
, assign(InputIterator, InputIterator)
, assign(capacity_type, InputIterator, InputIterator)
Параметры: |
| ||
Почтовые условия: |
| ||
Throws: | Ошибка распределения, если память исчерпана (std::bad_alloc , если используется стандартный аллокатор). Какой бы ни был бросок T::T(const T&) . |
Exception Safety. Strong.
Iterator Invalidation. Invalidates all iterators pointing to this
(except iterators equal to circular_buffer
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)
Parameters: |
| ||
Postconditions: |
| ||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
Сложность. Состоян.
Параметры: |
| ||
Требования: | C++ компилятор с поддержкой rvalue-ссылок. | ||
Почтовые условия: |
| ||
Throws: | Ничего. |
Complexity. Constant.
Parameters: |
| ||
Requires: | C++ compiler with rvalue references support. | ||
Postconditions: |
| ||
Throws: | Nothing. |
~circular_buffer();The destructor.
Destroys the
.
circular_buffer
Iterator Invalidation. Invalidates all iterators pointing to the
(including iterators equal to circular_buffer
end()
).
Complexity. Constant (in the size of the
) for scalar types; linear for other types. circular_buffer
See Also:
clear()
Throws: | Nothing. |
circular_buffer
public member functionsallocator_type get_allocator() const noexcept;Get the allocator.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
get_allocator()
for obtaining an allocator reference.
Returns: | The allocator. |
Throws: | Nothing. |
allocator_type & get_allocator() noexcept;Get the allocator reference.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
![]() | Note |
---|---|
This method was added in order to optimize obtaining of the allocator with a state, although use of stateful allocators in STL is discouraged. |
See Also:
get_allocator() const
Returns: | A reference to the allocator. |
Throws: | Nothing. |
iterator begin() noexcept;Get the iterator pointing to the beginning of the
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
end()
, rbegin()
, rend()
Returns: | A random access iterator pointing to the first element of the |
Throws: | Nothing. |
iterator end() noexcept;Get the iterator pointing to the end of the
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
begin()
, rbegin()
, rend()
Returns: | A random access iterator pointing to the element "one behind" the last element of the |
Throws: | Nothing. |
const_iterator begin() const noexcept;Get the const iterator pointing to the beginning of the
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
end() const
, rbegin() const
, rend() const
Returns: | A const random access iterator pointing to the first element of the |
Throws: | Nothing. |
const_iterator end() const noexcept;Get the const iterator pointing to the end of the
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
begin() const
, rbegin() const
, rend() const
Returns: | A const random access iterator pointing to the element "one behind" the last element of the |
Throws: | Nothing. |
reverse_iterator rbegin() noexcept;Get the iterator pointing to the beginning of the "reversed"
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
rend()
, begin()
, end()
Returns: | A reverse random access iterator pointing to the last element of the |
Throws: | Nothing. |
reverse_iterator rend() noexcept;Get the iterator pointing to the end of the "reversed"
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
rbegin()
, begin()
, end()
Returns: | A reverse random access iterator pointing to the element "one before" the first element of the |
Throws: | Nothing. |
const_reverse_iterator rbegin() const noexcept;Get the const iterator pointing to the beginning of the "reversed"
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
rend() const
, begin() const
, end() const
Returns: | A const reverse random access iterator pointing to the last element of the |
Throws: | Nothing. |
const_reverse_iterator rend() const noexcept;Get the const iterator pointing to the end of the "reversed"
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
rbegin() const
, begin() const
, end() const
Returns: | A const reverse random access iterator pointing to the element "one before" the first element of the |
Throws: | Nothing. |
reference operator[](size_type index);Get the element at the
index
position.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
at()
Parameters: |
| ||
Requires: |
| ||
Returns: | A reference to the element at the | ||
Throws: | Nothing. |
const_reference operator[](size_type index) const;Get the element at the
index
position.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
at() const
Parameters: |
| ||
Requires: |
| ||
Returns: | A const reference to the element at the | ||
Throws: | Nothing. |
Сохранность восприятия. Стенок.
Удостоверение. Не аннулирует ни один итератор.
Сложность. Состояние (в размере
). circular_buffer
См. также:
operator[]
Параметры: |
| ||
Возвращение: | Ссылка на элемент в позиции | ||
Throws: | std::out_of_range когда index является недействительным (когда index >= size() ). |
Exception Safety. Strong.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
operator[]
Parameters: |
| ||
Returns: | A reference to the element at the | ||
Throws: | <code>std::out_of_range</code> when the index is invalid (when index >= size() ). |
const_reference at(size_type index) const;Get the element at the
index
position.
Exception Safety. Strong.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
operator[] const
Parameters: |
| ||
Returns: | A const reference to the element at the | ||
Throws: | <code>std::out_of_range</code> when the index is invalid (when index >= size() ). |
reference front();Get the first element.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
back()
Requires: |
|
Returns: | A reference to the first element of the |
Throws: | Nothing. |
Безопасность принятия. Нет-трой.
Удостоверение. Не аннулирует ни один итератор.
Сложность. Состояние (в размере
). circular_buffer
См. также:
front()
Требования: | |
Возвращение: | Ссылка на последний элемент |
Throws: | Ничего. |
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
front()
Requires: |
|
Returns: | A reference to the last element of the |
Throws: | Nothing. |
const_reference front() const;Get the first element.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
back() const
Requires: |
|
Returns: | A const reference to the first element of the |
Throws: | Nothing. |
const_reference back() const;Get the last element.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
front() const
Requires: |
|
Returns: | A const reference to the last element of the |
Throws: | Nothing. |
array_range array_one();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
of capacity 10, containing 7 characters circular_buffer
'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
into a file. Either relying on circular_buffer
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.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
![]() | Warning |
---|---|
In general invoking any method which modifies the internal state of the |
![]() | Note |
---|---|
In the case the internal buffer is linear e.g. |
See Also:
array_two()
, linearize()
Returns: | The array range of the first continuous array of the internal buffer. In the case the |
Throws: | Nothing. |
array_range array_two();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.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
array_one()
Returns: | The array range of the second continuous array of the internal buffer. In the case the internal buffer is linear or the |
Throws: | Nothing. |
const_array_range array_one() const;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.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
array_two() const
; array_one()
for more details how to pass data into a legacy C API.
Returns: | The array range of the first continuous array of the internal buffer. In the case the |
Throws: | Nothing. |
const_array_range array_two() const;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.
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
array_one() const
Returns: | The array range of the second continuous array of the internal buffer. In the case the internal buffer is linear or the |
Throws: | Nothing. |
pointer linearize();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.
Exception Safety. Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
end()
); does not invalidate any iterators if the postcondition (the Effect) is already met prior calling this method.
Complexity. Linear (in the size of the
); constant if the postcondition (the Effect) is already met. circular_buffer
![]() | Warning |
---|---|
In general invoking any method which modifies the internal state of the |
See Also:
array_one()
and array_two()
for the other option how to pass data into a legacy C API; is_linearized()
, rotate(const_iterator)
Postconditions: |
|
Returns: | A pointer to the beginning of the array or |
Throws: | <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
bool is_linearized() const noexcept;Is the
circular_buffer
linearized? Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
linearize()
, array_one()
, array_two()
Returns: |
|
Throws: | Nothing. |
void rotate(const_iterator new_begin);Rotate elements in the
circular_buffer
. A more effective implementation of std::rotate
.
Exception Safety. Basic; no-throw if the
is full or circular_buffer
new_begin
points to begin()
or if the operations in the Throws section do not throw anything.
Iterator Invalidation. If 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
is full. circular_buffer
Complexity. Linear (in (std::min)(m, n)
); constant if the
is full. circular_buffer
See Also:
Parameters: |
| ||
Requires: |
| ||
Postconditions: | Before calling the method suppose: | ||
Throws: | See Exceptions of move_if_noexcept(T&). |
size_type size() const noexcept;Get the number of elements currently stored in the
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
capacity()
, max_size()
, reserve()
, resize(size_type, const_reference)
Returns: | The number of elements stored in the |
Throws: | Nothing. |
size_type max_size() const noexcept;Get the largest possible size or capacity of the
circular_buffer
. (It depends on allocator's max_size()). Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
size()
, capacity()
, reserve()
Returns: | The maximum size/capacity the |
Throws: | Nothing. |
Безопасность принятия. Нет-трой.
Удостоверение. Не аннулирует ни один итератор.
Сложность. Состояние (в размере
). circular_buffer
См. также:
full()
Возвращение: |
|
Throws: | Ничего. |
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
full()
Returns: |
|
Throws: | Nothing. |
bool full() const noexcept;Is the
circular_buffer
full? Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
empty()
Returns: |
|
Throws: | Nothing. |
Безопасность принятия. Нет-трой.
Удостоверение. Не аннулирует ни один итератор.
Сложность. Состояние (в размере
). circular_buffer
См. также:
capacity()
, size()
, max_size()
Возвращение: |
|
Throws: | Ничего. |
Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
capacity()
, size()
, max_size()
Returns: |
|
Throws: | Nothing. |
capacity_type capacity() const noexcept;Get the capacity of the
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Does not invalidate any iterators.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
reserve()
, size()
, max_size()
, set_capacity(capacity_type)
Returns: | The maximum number of elements which can be stored in the |
Throws: | Nothing. |
void set_capacity(capacity_type new_capacity);Change the capacity of the
circular_buffer
.
Exception Safety. Strong.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
end()
) if the new capacity is different from the original.
Complexity. Linear (in min[size(), new_capacity]
).
See Also:
rset_capacity(capacity_type)
, resize(size_type, const_reference)
Parameters: |
| ||
Requires: | If | ||
Postconditions: |
| ||
Throws: | 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. |
void resize(size_type new_size, param_value_type item = value_type());Change the size of the
circular_buffer
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
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.
Complexity. Linear (in the new size of the
). circular_buffer
See Also:
rresize(size_type, const_reference)
, set_capacity(capacity_type)
Parameters: |
| ||||
Postconditions: |
| ||||
Throws: | 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. |
void rset_capacity(capacity_type new_capacity);Change the capacity of the
circular_buffer
.
Exception Safety. Strong.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
end()
) if the new capacity is different from the original.
Complexity. Linear (in min[size(), new_capacity]
).
See Also:
set_capacity(capacity_type)
, rresize(size_type, const_reference)
Parameters: |
| ||
Requires: | If | ||
Postconditions: |
| ||
Throws: | 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. |
void rresize(size_type new_size, param_value_type item = value_type());Change the size of the
circular_buffer
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
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.
Complexity. Linear (in the new size of the
). circular_buffer
See Also:
resize(size_type, const_reference)
, rset_capacity(capacity_type)
Parameters: |
| ||||
Postconditions: |
| ||||
Throws: | 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. |
void assign(size_type n, param_value_type item);Assign
n
items into the circular_buffer
. The content of the
will be removed and replaced with circular_buffer
n
copies of the item
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
end()
).
Complexity. Linear (in the n
).
See Also:
operator=
, assign(capacity_type, size_type, const_reference)
, assign(InputIterator, InputIterator)
, assign(capacity_type, InputIterator, InputIterator)
Parameters: |
| ||||
Postconditions: |
| ||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
void assign(capacity_type buffer_capacity, size_type n, param_value_type item);Assign
n
items into the circular_buffer
specifying the capacity. The capacity of the
will be set to the specified value and the content of the circular_buffer
will be removed and replaced with circular_buffer
n
copies of the item
.
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
end()
).
Complexity. Linear (in the n
).
See Also:
operator=
, assign(size_type, const_reference)
, assign(InputIterator, InputIterator)
, assign(capacity_type, InputIterator, InputIterator)
Parameters: |
| ||||||
Requires: |
| ||||||
Postconditions: |
| ||||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
Безопасность принятия. Базовый.
Удостоверение. Указывает все итераторы, указывающие на
(за исключением итераторов, равных circular_buffer
end()
).
Complexity. Linear (в std::distance(first, last)
).
См. также:
operator=
, assign(size_type, const_reference)
, assign(capacity_type, size_type, const_reference)
, assign(capacity_type, InputIterator, InputIterator)
Параметры: |
| ||||
Требования: | Valid range | ||||
Почтовые условия: |
| ||||
Throws: | Ошибка распределения, если память исчерпана (std::bad_alloc , если используется стандартный аллокатор). Какой бы ни был бросок T::T(const T&) . |
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
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)
Parameters: |
| ||||
Requires: | Valid range | ||||
Postconditions: |
| ||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
Безопасность принятия. Базовый.
Удостоверение. Указывает все итераторы, указывающие на
(за исключением итераторов, равных circular_buffer
end()
).
См. также:
operator=
, assign(size_type, const_reference)
, assign(capacity_type, size_type, const_reference)
, assign(InputIterator, InputIterator)
Параметры: |
| ||||||
Требования: | Valid range | ||||||
Почтовые условия: |
| ||||||
Throws: | Ошибка распределения, если память исчерпана (std::bad_alloc , если используется стандартный аллокатор). Какой бы ни был бросок T::T(const T&) . |
Exception Safety. Basic.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
end()
).
Complexity. Linear (in std::distance(first, last)
; in min[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)
Parameters: |
| ||||||
Requires: | Valid range | ||||||
Postconditions: |
| ||||||
Throws: | An allocation error if memory is exhausted (std::bad_alloc if the standard allocator is used). Whatever T::T(const T&) throws. |
void swap(circular_buffer< T, Alloc > & cb) noexcept;Swap the contents of two
circular_buffer
s.
Exception Safety. No-throw.
Iterator Invalidation. Invalidates all iterators of both
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
Complexity. Constant (in the size of the
). circular_buffer
See Also:
swap(circular_buffer<T, Alloc>&, circular_buffer<T, Alloc>&)
Parameters: |
| ||
Postconditions: |
| ||
Throws: | Nothing. |
void push_back(param_value_type item);Insert a new element at the end of the
circular_buffer
.
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
push_front(const_reference)
, pop_back()
, pop_front()
Parameters: |
| ||
Postconditions: | if | ||
Throws: | Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
void push_back(rvalue_type item);Insert a new element at the end of the
circular_buffer
using rvalue references or rvalues references emulation.
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
push_front(const_reference)
, pop_back()
, pop_front()
Parameters: |
| ||
Postconditions: | if | ||
Throws: | Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. |
Сохранность восприятия. Basic; no-throw если операция в Throws раздел ничего не бросает.
Удостоверение. Не аннулирует ни один итератор, за исключением итераторов, указывающих на записанные элементы.
Сложность. Состояние (в размере
). circular_buffer
См. также:
push_front(const_reference)
, pop_back()
, pop_front()
Почтовые условия: | if |
Throws: | Какие бы ни были броски T::T() . Что угодно T::T(T&&) бросает. Какой бы ни был бросок T::operator = (T&&) . |
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
push_front(const_reference)
, pop_back()
, pop_front()
Postconditions: | if |
Throws: | Whatever T::T() throws. Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. |
Сохранность восприятия. Basic; no-throw если операция в Throws раздел ничего не бросает.
Удостоверение. Не аннулирует ни один итератор, за исключением итераторов, указывающих на записанные элементы.
Сложность. Состояние (в размере
). circular_buffer
См. также:
push_back(const_reference)
, pop_back()
, pop_front()
Параметры: |
| ||
Почтовые условия: | if | ||
Throws: | Какие бы T::T(const T&) ни были броски. Какой бы ни был бросок T::operator = (const T&) . |
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
push_back(const_reference)
, pop_back()
, pop_front()
Parameters: |
| ||
Postconditions: | if | ||
Throws: | Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. |
void push_front(rvalue_type item);Insert a new element at the beginning of the
circular_buffer
using rvalue references or rvalues references emulation.
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
push_back(const_reference)
, pop_back()
, pop_front()
Parameters: |
| ||
Postconditions: | if | ||
Throws: | Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. |
void push_front();Insert a new default-constructed element at the beginning of the
circular_buffer
. Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
push_back(const_reference)
, pop_back()
, pop_front()
Postconditions: | if |
Throws: | Whatever T::T() throws. Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. |
void pop_back();Remove the last element from the
circular_buffer
.
Exception Safety. No-throw.
Iterator Invalidation. Invalidates only iterators pointing to the removed element.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
pop_front()
, push_back(const_reference)
, push_front(const_reference)
Requires: |
|
Postconditions: | The last element is removed from the |
Throws: | Nothing. |
void pop_front();Remove the first element from the
circular_buffer
.
Exception Safety. No-throw.
Iterator Invalidation. Invalidates only iterators pointing to the removed element.
Complexity. Constant (in the size of the
). circular_buffer
See Also:
pop_back()
, push_back(const_reference)
, push_front(const_reference)
Requires: |
|
Postconditions: | The first element is removed from the |
Throws: | Nothing. |
Сохранность восприятия. Basic; no-throw если операция в Throws раздел ничего не бросает.
Удостоверение. Установляет итераторы, указывающие на элементы в точке вставки (включая pos
) и итераторы за точкой вставки (к концу; кроме итераторов, равных end()
). Он также аннулирует итераторы, указывающие на переписанные элементы.
Complexity. Linear (в 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)
Параметры: |
| ||||
Требования: |
| ||||
Почтовые условия: | The | ||||
Возвращение: | Установщик вставленного элемента или | ||||
Throws: | Какой бы ни был T::T(const T&) бросок. T::operator = (const T&) броски. Исключения move_if_no except(T&). |
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements at the insertion point (including pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten element.
Complexity. Linear (in std::distance(pos, end())
).
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)
Parameters: |
| ||||
Requires: |
| ||||
Postconditions: | The | ||||
Returns: | Iterator to the inserted element or | ||||
Throws: | Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. Exceptions of move_if_noexcept(T&). |
Сохранность восприятия. Basic; no-throw если операция в Throws раздел ничего не бросает.
Удостоверение. Установляет итераторы, указывающие на элементы в точке вставки (включая pos
) и итераторы за точкой вставки (к концу; кроме итераторов, равных end()
). Он также аннулирует итераторы, указывающие на переписанные элементы.
Complexity. Linear (в 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)
Параметры: |
| ||||
Требования: |
| ||||
Почтовые условия: | The | ||||
Возвращение: | Установщик вставленного элемента или | ||||
Throws: | Какие бы ни были броски T::T(T&&) . Exceptions of move_if_no except(T&). |
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements at the insertion point (including pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten element.
Complexity. Linear (in std::distance(pos, end())
).
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)
Parameters: |
| ||||
Requires: |
| ||||
Postconditions: | The | ||||
Returns: | Iterator to the inserted element or | ||||
Throws: | Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. Exceptions of move_if_noexcept(T&). |
iterator insert(iterator pos);Insert a default-constructed element at the specified position.
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements at the insertion point (including pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten element.
Complexity. Linear (in std::distance(pos, end())
).
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)
Parameters: |
| ||
Requires: |
| ||
Postconditions: | The | ||
Returns: | Iterator to the inserted element or | ||
Throws: | Whatever T::T() throws. Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. Exceptions of move_if_noexcept(T&). |
void insert(iterator pos, size_type n, param_value_type item);Insert
n
copies of the item
at the specified position.
Exception Safety. Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements at the insertion point (including pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten elements.
Complexity. Linear (in min[capacity(), std::distance(pos, end()) + n]
).
Example. Consider a
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.circular_buffer
|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)
Parameters: |
| ||||||
Requires: |
| ||||||
Postconditions: | The number of | ||||||
Throws: | Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. Exceptions of move_if_noexcept(T&). |
template<typename InputIterator> void insert(iterator pos, InputIterator first, InputIterator last);Insert the range
[first, last)
at the specified position.
Exception Safety. Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements at the insertion point (including pos
) and iterators behind the insertion point (towards the end; except iterators equal to end()
). It also invalidates iterators pointing to the overwritten elements.
Complexity. Linear (in [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).
Example. Consider a
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.circular_buffer
|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)
Parameters: |
| ||||||
Requires: |
| ||||||
Postconditions: | Elements from the range | ||||||
Throws: | 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. |
iterator rinsert(iterator pos, param_value_type item);Insert an element before the specified position.
Exception Safety. Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements before the insertion point (towards the beginning and excluding pos
). It also invalidates iterators pointing to the overwritten element.
Complexity. Linear (in std::distance(begin(), pos)
).
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)
Parameters: |
| ||||
Requires: |
| ||||
Postconditions: | The | ||||
Returns: | Iterator to the inserted element or | ||||
Throws: | Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. Exceptions of move_if_noexcept(T&). |
iterator rinsert(iterator pos, rvalue_type item);Insert an element before the specified position.
Exception Safety. Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements before the insertion point (towards the beginning and excluding pos
). It also invalidates iterators pointing to the overwritten element.
Complexity. Linear (in std::distance(begin(), pos)
).
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)
Parameters: |
| ||||
Requires: |
| ||||
Postconditions: | The | ||||
Returns: | Iterator to the inserted element or | ||||
Throws: | Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. Exceptions of move_if_noexcept(T&). |
iterator rinsert(iterator pos);Insert an element before the specified position.
Exception Safety. Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements before the insertion point (towards the beginning and excluding pos
). It also invalidates iterators pointing to the overwritten element.
Complexity. Linear (in std::distance(begin(), pos)
).
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)
Parameters: |
| ||
Requires: |
| ||
Postconditions: | The | ||
Returns: | Iterator to the inserted element or | ||
Throws: | Whatever T::T() throws. Whatever T::T(T&&) throws. Whatever T::operator = (T&&) throws. Exceptions of move_if_noexcept(T&). |
void rinsert(iterator pos, size_type n, param_value_type item);Insert
n
copies of the item
before the specified position.
Exception Safety. Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements before the insertion point (towards the beginning and excluding pos
). It also invalidates iterators pointing to the overwritten elements.
Complexity. Linear (in min[capacity(), std::distance(begin(), pos) + n]
).
Example. Consider a
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.circular_buffer
|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)
Parameters: |
| ||||||
Requires: |
| ||||||
Postconditions: | The number of | ||||||
Throws: | Whatever T::T(const T&) throws. Whatever T::operator = (const T&) throws. Exceptions of move_if_noexcept(T&). |
template<typename InputIterator> void rinsert(iterator pos, InputIterator first, InputIterator last);Insert the range
[first, last)
before the specified position.
Exception Safety. Basic; no-throw if the operations in the Throws section do not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the elements before the insertion point (towards the beginning and excluding pos
). It also invalidates iterators pointing to the overwritten elements.
Complexity. Linear (in [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).
Example. Consider a
with the capacity of 6 and the size of 4. Its internal buffer may look like the one below.circular_buffer
|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)
Parameters: |
| ||||||
Requires: |
| ||||||
Postconditions: | Elements from the range | ||||||
Throws: | 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. |
iterator erase(iterator pos);Remove an element at the specified position.
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the erased element and iterators pointing to the elements behind the erased element (towards the end; except iterators equal to end()
).
Complexity. Linear (in std::distance(pos, end())
).
See Also:
erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, erase_end(size_type)
, clear()
Parameters: |
| ||
Requires: |
| ||
Postconditions: | The element at the position | ||
Returns: | Iterator to the first element remaining beyond the removed element or | ||
Throws: | <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
iterator erase(iterator first, iterator last);Erase the range
[first, last)
.
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the erased elements and iterators pointing to the elements behind the erased range (towards the end; except iterators equal to end()
).
Complexity. Linear (in std::distance(first, end())
).
See Also:
erase(iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, erase_end(size_type)
, clear()
Parameters: |
| ||||
Requires: | Valid range | ||||
Postconditions: | The elements from the range | ||||
Returns: | Iterator to the first element remaining beyond the removed elements or | ||||
Throws: | <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
iterator rerase(iterator pos);Remove an element at the specified position.
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the erased element and iterators pointing to the elements in front of the erased element (towards the beginning).
Complexity. Linear (in std::distance(begin(), pos)
).
![]() | Note |
---|---|
This method is symetric to the |
See Also:
erase(iterator)
, erase(iterator, iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, erase_end(size_type)
, clear()
Parameters: |
| ||
Requires: |
| ||
Postconditions: | The element at the position | ||
Returns: | Iterator to the first element remaining in front of the removed element or | ||
Throws: | <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
iterator rerase(iterator first, iterator last);Erase the range
[first, last)
.
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything.
Iterator Invalidation. Invalidates iterators pointing to the erased elements and iterators pointing to the elements in front of the erased range (towards the beginning).
Complexity. Linear (in std::distance(begin(), last)
).
![]() | Note |
---|---|
This method is symetric to the |
See Also:
erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, erase_begin(size_type)
, erase_end(size_type)
, clear()
Parameters: |
| ||||
Requires: | Valid range | ||||
Postconditions: | The elements from the range | ||||
Returns: | Iterator to the first element remaining in front of the removed elements or | ||||
Throws: | <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
void erase_begin(size_type n);Remove first
n
elements (with constant complexity for scalar types).
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything. (I.e. no throw in case of scalars.)
Iterator Invalidation. Invalidates iterators pointing to the first n
erased elements.
Complexity. Constant (in n
) for scalar types; linear for other types.
![]() | Note |
---|---|
This method has been specially designed for types which do not require an explicit destructruction (e.g. integer, float or a pointer). For these scalar types a call to a destructor is not required which makes it possible to implement the "erase from beginning" operation with a constant complexity. For non-sacalar types the complexity is linear (hence the explicit destruction is needed) and the implementation is actually equivalent to |
See Also:
erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_end(size_type)
, clear()
Parameters: |
| ||
Requires: |
| ||
Postconditions: | The | ||
Throws: | <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
Сохранность восприятия. Basic; no-throw если операция в Throws раздел ничего не бросает. (I.e. без броска в случае скаляров.)
Удостоверение. Установляет итераторы, указывающие на последние n
стертые элементы.
Сложность. Стант (в n
) для скалярных типов; линейный для других типов.
![]() | Note |
---|---|
Этот метод был специально разработан для типов, которые не требуют явной деструкции (например, целых чисел, поплавков или указателя). Для этих типов скаляров не требуется призыв к деструктору, что позволяет осуществлять операцию «удары от конца» с постоянной сложностью. Для нетакалярных типов сложность линейна (отсюда требуется явное уничтожение), и реализация на самом деле эквивалентна |
См. также:
erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, clear()
Параметры: |
| ||
Требования: |
| ||
Почтовые условия: | Элементы | ||
Throws: | Exceptions of move_if_no except(T&). |
Exception Safety. Basic; no-throw if the operation in the Throws section does not throw anything. (I.e. no throw in case of scalars.)
Iterator Invalidation. Invalidates iterators pointing to the last n
erased elements.
Complexity. Constant (in n
) for scalar types; linear for other types.
![]() | Note |
---|---|
This method has been specially designed for types which do not require an explicit destructruction (e.g. integer, float or a pointer). For these scalar types a call to a destructor is not required which makes it possible to implement the "erase from end" operation with a constant complexity. For non-sacalar types the complexity is linear (hence the explicit destruction is needed) and the implementation is actually equivalent to |
See Also:
erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, clear()
Parameters: |
| ||
Requires: |
| ||
Postconditions: | The | ||
Throws: | <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&). |
void clear() noexcept;Remove all stored elements from the
circular_buffer
. Exception Safety. No-throw.
Iterator Invalidation. Invalidates all iterators pointing to the
(except iterators equal to circular_buffer
end()
).
Complexity. Constant (in the size of the
) for scalar types; linear for other types. circular_buffer
See Also:
~circular_buffer()
, erase(iterator)
, erase(iterator, iterator)
, rerase(iterator)
, rerase(iterator, iterator)
, erase_begin(size_type)
, erase_end(size_type)
Postconditions: |
|
Throws: | Nothing. |
circular_buffer
private member functionstemplate<typename ValT>voidpush_back_impl(ValT item;
template<typename ValT>voidpush_front_impl(ValT item;
template<typename ValT> iteratorinsert_impl(iterator pos, ValT item;
template<typename ValT> iteratorrinsert_impl(iterator pos, ValT item;
void check_position(size_type index) const;Check if the
index
is valid. template<typename Pointer> void increment(Pointer & p) const;Increment the pointer.
template<typename Pointer> void decrement(Pointer & p) const;Decrement the pointer.
template<typename Pointer> Pointer add(Pointer p, difference_type n) const;Add
n
to the pointer. template<typename Pointer> Pointer sub(Pointer p, difference_type n) const;Subtract
n
from the pointer. pointer map_pointer(pointer p) const;Map the null pointer to virtual end of circular buffer.
pointer allocate(size_type n);Allocate memory.
void deallocate(pointer p, size_type n);Deallocate memory.
bool is_uninitialized(const_pointer p) const noexcept;Does the pointer point to the uninitialized memory?
void replace(pointer pos, param_value_type item);Replace an element.
void replace(pointer pos, rvalue_type item);Replace an element.
void construct_or_replace(bool construct, pointer pos, param_value_type item);Construct or replace an element.
construct
has to be set to true
if and only if pos
points to an uninitialized memory.
void construct_or_replace(bool construct, pointer pos, rvalue_type item);Construct or replace an element.
construct
has to be set to true
if and only if pos
points to an uninitialized memory.
void destroy_item(pointer p);Destroy an item.
void destroy_if_constructed(pointer pos);Destroy an item only if it has been constructed.
void destroy_content();Destroy the whole content of the circular buffer.
void destroy_content(const true_type &);Specialized destroy_content method.
void destroy_content(const false_type &);Specialized destroy_content method.
void destroy() noexcept;Destroy content and free allocated memory.
void initialize_buffer(capacity_type buffer_capacity);Initialize the internal buffer.
void initialize_buffer(capacity_type buffer_capacity, param_value_type item);Initialize the internal buffer.
template<typename IntegralType> void initialize(IntegralType n, IntegralType item, const true_type &);Specialized initialize method.
template<typename Iterator> void initialize(Iterator first, Iterator last, const false_type &);Specialized initialize method.
template<typename InputIterator> void initialize(InputIterator first, InputIterator last, const std::input_iterator_tag &);Specialized initialize method.
template<typename ForwardIterator> void initialize(ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &);Specialized initialize method.
template<typename IntegralType> void initialize(capacity_type buffer_capacity, IntegralType n, IntegralType item, const true_type &);Specialized initialize method.
template<typename Iterator> void initialize(capacity_type buffer_capacity, Iterator first, Iterator last, const false_type &);Specialized initialize method.
templatetypenameInputIterator>voidinitialize(buffer_capacity,InputIteratorfirst,InputIterator last,conststd::&;Специализированный метод инициализации.
template<typename ForwardIterator> void initialize(capacity_type buffer_capacity, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &);Specialized initialize method.
template<typename ForwardIterator> void initialize(capacity_type buffer_capacity, ForwardIterator first, ForwardIterator last, size_type distance);Initialize the circular buffer.
void reset(pointer buff, pointer last, capacity_type new_capacity);Reset the circular buffer.
void swap_allocator(circular_buffer< T, Alloc > &, const true_type &);Specialized method for swapping the allocator.
void swap_allocator(circular_buffer< T, Alloc > & cb, const false_type &);Specialized method for swapping the allocator.
template<typename IntegralType> void assign(IntegralType n, IntegralType item, const true_type &);Specialized assign method.
template<typename Iterator> void assign(Iterator first, Iterator last, const false_type &);Specialized assign method.
template<typename InputIterator> void assign(InputIterator first, InputIterator last, const std::input_iterator_tag &);Specialized assign method.
template<typename ForwardIterator> void assign(ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &);Specialized assign method.
template<typename IntegralType> void assign(capacity_type new_capacity, IntegralType n, IntegralType item, const true_type &);Specialized assign method.
template<typename Iterator> void assign(capacity_type new_capacity, Iterator first, Iterator last, const false_type &);Specialized assign method.
templatetypenameInputIterator>voidassign( new_capacity, InputIterator first, InputIterator last, const::input_iterator_tag &;Специализированный способ назначения.
template<typename ForwardIterator> void assign(capacity_type new_capacity, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &);Specialized assign method.
template<typename Functor> void assign_n(capacity_type new_capacity, size_type n, const Functor & fnc);Helper assign method.
template<typename ValT> iterator insert_item(const iterator & pos, ValT item);Helper insert method.
template<typename IntegralType> void insert(const iterator & pos, IntegralType n, IntegralType item, const true_type &);Specialized insert method.
template<typename Iterator> void insert(const iterator & pos, Iterator first, Iterator last, const false_type &);Specialized insert method.
template<typename InputIterator> void insert(iterator pos, InputIterator first, InputIterator last, const std::input_iterator_tag &);Specialized insert method.
template<typename ForwardIterator> void insert(const iterator & pos, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &);Specialized insert method.
template<typename Wrapper> void insert_n(const iterator & pos, size_type n, const Wrapper & wrapper);Helper insert method.
template<typename IntegralType> void rinsert(const iterator & pos, IntegralType n, IntegralType item, const true_type &);Specialized rinsert method.
template<typename Iterator> void rinsert(const iterator & pos, Iterator first, Iterator last, const false_type &);Specialized rinsert method.
template<typename InputIterator> void rinsert(iterator pos, InputIterator first, InputIterator last, const std::input_iterator_tag &);Specialized insert method.
template<typename ForwardIterator> void rinsert(const iterator & pos, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag &);Specialized rinsert method.
template<typename Wrapper> void rinsert_n(const iterator & pos, size_type n, const Wrapper & wrapper);Helper rinsert method.
void erase_begin(size_type n, const true_type &);Specialized erase_begin method.
void erase_begin(size_type n, const false_type &);Specialized erase_begin method.
void erase_end(size_type n, const true_type &);Specialized erase_end method.
void erase_end(size_type n, const false_type &);Specialized erase_end method.
Статья Class template circular_buffer раздела The Boost C++ Libraries BoostBook Documentation Subset Boost.Circular_buffer C++ Reference может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.
:: Главная :: Boost.Circular_buffer C++ Reference ::
реклама |