circular_buffer
T
insert(iterator pos, const value_type& item = %value_type())
Alloc
std::pair
size_type
circular_buffer_space_optimized
get_allocator()
get_allocator() const
end()
rbegin()
rend()
begin()
end() const
rbegin() const
rend() const
begin() const
index
0 \<= index \&\& index \< size()
at()
\link at(size_type)const at() const \endlink
std::out_of_range
index >= size()
operator[]
\link operator[](size_type)const operator[] const \endlink
!empty()
back()
front()
back() const
front() const
array_two()
'a', 'b', ..., 'g'
buff[0] == 'a'
buff[1] == 'b'
buff[6] == 'g'
circular_buffer buff(10);
|e|f|g| | | |a|b|c|d| end ---^ begin -------^
|a|b|c|d|
|e|f|g|
| | | |
int write(int file_desc, char* buff, int num_bytes);
array_one()
array_range ar = buff.array_one(); write(file_desc, ar.first, ar.second); ar = buff.array_two(); write(file_desc, ar.first, ar.second);
linearize()
write(file_desc, buff.linearize(), buff.size());
0
|a|b|c|d|e|f|g| | | |
|a|b|c|d|e|f|g|
array_two() const
array_one() const
\&(*this)[0] \< \&(*this)[1] \< ... \< \&(*this)[size() - 1]
T::T(const T&)
T::operator = (const T&)
capacity()
max_size()
reserve()
\link resize() resize(size_type, const_reference)\endlink
size()
true
false
full()
empty()
capacity() - size()
set_capacity(capacity_type)
capacity() == new_capacity \&\& size() \<= new_capacity
[size() - new_capacity]
new_capacity
std::bad_alloc
min[size(), new_capacity]
rset_capacity(capacity_type)
size() == new_size \&\& capacity() >= new_size
item
new_size
[size() - new_size]
\link rresize() rresize(size_type, const_reference)\endlink
capacity() == max_size() \&\& size() == 0
capacity() == capacity \&\& size() == 0
n
capacity() == n \&\& full() \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ... \&\& (*this)[n - 1] == item
capacity >= n
capacity() == capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ... \&\& (*this)[n - 1] == item
*this == cb
cb
[first, last)
first
last
capacity() == std::distance(first, last) \&\& full() \&\& (*this)[0]== *first \&\& (*this)[1] == *(first + 1) \&\& ... \&\& (*this)[std::distance(first, last) - 1] == *(last - 1)
std::distance(first, last)
capacity() == capacity \&\& size() \<= std::distance(first, last) \&\& (*this)[0]== *(last - capacity) \&\& (*this)[1] == *(last - capacity + 1) \&\& ... \&\& (*this)[capacity - 1] == *(last - 1)
capacity
[last - capacity, last)
min[capacity, std::distance(first, last)]
InputIterator
clear()
\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink
\link assign(capacity_type, size_type, param_value_type) assign(capacity_type, size_type, const_reference)\endlink
assign(InputIterator, InputIterator)
assign(capacity_type, InputIterator, InputIterator)
capacity() == n \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ... \&\& (*this) [n - 1] == item
operator=
capacity() == capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ... \&\& (*this) [n - 1] == item
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)
this
swap(circular_buffer&, circular_buffer&)
capacity() > 0
back() == item
\link push_front() push_front(const_reference)\endlink
pop_back()
pop_front()
front() == item
\link push_back() push_back(const_reference)\endlink
pos
std::distance(pos, end())
\link insert(iterator, size_type, param_value_type) insert(iterator, size_type, value_type)\endlink
insert(iterator, InputIterator, InputIterator)
\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink
\link rinsert(iterator, size_type, param_value_type) rinsert(iterator, size_type, value_type)\endlink
rinsert(iterator, InputIterator, InputIterator)
min[n, (pos - begin()) + reserve()]
min[pos - begin(), max[0, n - reserve()]]
min[capacity(), std::distance(pos, end()) + n]
|1|2|3|4| | |
p ---^
p
insert(p, (size_t)5, 0);
1
2
|0|0|0|0|3|4|
|1|2|0|0|0|0|0|3|4|
\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink
[first + max[0, distance(first, last) - (pos - begin()) - reserve()], last)
min[pos - begin(), max[0, distance(first, last) - reserve()]]
[std::distance(pos, end()) + std::distance(first, last)]
min[capacity(), std::distance(pos, end()) + std::distance(first, last)]
int array[] = { 5, 6, 7, 8, 9 };
insert(p, array, array + 5);
6
7
8
9
|6|7|8|9|3|4|
|1|2|5|6|7|8|9|3|4|
std::distance(begin(), pos)
min[n, (end() - pos) + reserve()]
min[end() - pos, max[0, n - reserve()]]
min[capacity(), std::distance(begin(), pos) + n]
rinsert(p, (size_t)5, 0);
3
4
|1|2|0|0|0|0|
[first, last - max[0, distance(first, last) - (end() - pos) - reserve()])
min[end() - pos, max[0, distance(first, last) - reserve()]]
[std::distance(begin(), pos) + std::distance(first, last)]
min[capacity(), std::distance(begin(), pos) + std::distance(first, last)]
5
|1|2|5|6|7|8|
erase(iterator, iterator)
rerase(iterator)
rerase(iterator, iterator)
first == last
std::distance(first, end())
erase(iterator)
std::distance(begin(), last)
std::distance(begin(), first)
std::distance(last, end())
size() == 0
~circular_buffer()
construct
lhs.\link circular_buffer::size() size()\endlink == rhs.\link circular_buffer::size() size()\endlink && std::equal(lhs.\link circular_buffer::begin() begin()\endlink, lhs.\link circular_buffer::end() end()\endlink, rhs.\link circular_buffer::begin() begin()\endlink)
std::lexicographical_compare(lhs.\link circular_buffer::begin() begin()\endlink, lhs.\link circular_buffer::end() end()\endlink, rhs.\link circular_buffer::begin() begin()\endlink, rhs.\link circular_buffer::end() end()\endlink)
!(lhs == rhs)
operator==(const circular_buffer&, const circular_buffer&)
rhs \< lhs
operator<(const circular_buffer&, const circular_buffer&)
!(rhs \< lhs)
!(lhs < rhs)
lhs
rhs
\link circular_buffer::swap(circular_buffer&) swap(circular_buffer&)\endlink