boost::double_ended::batch_deque
// In header: <boost/double_ended/batch_deque.hpp> template<typename T, typename BatchDequePolicy = batch_deque_policy<512>, typename Allocator = std::allocator<T> > class batch_deque { public: // types typedef T value_type; typedef Allocator allocator_type; typedef value_type & reference; typedef const value_type & const_reference; typedef allocator_traits::pointer pointer; typedef allocator_traits::const_pointer const_pointer; typedef implementation_defined size_type; typedef implementation_defined difference_type; typedef implementation_defined iterator; typedef implementation_defined const_iterator; typedef std::reverse_iterator< iterator > reverse_iterator; typedef std::reverse_iterator< const_iterator > const_reverse_iterator; typedef implementation_defined segment_iterator; typedef implementation_defined const_segment_iterator; // construct/copy/destruct batch_deque(); explicit batch_deque(const Allocator &); explicit batch_deque(size_type, const Allocator & = Allocator()); batch_deque(size_type, const T &, const Allocator & = Allocator()); template<typename InputIterator> batch_deque(InputIterator, InputIterator, const Allocator & = Allocator()); batch_deque(const batch_deque &); batch_deque(const batch_deque &, const Allocator &); batch_deque(batch_deque &&); batch_deque(batch_deque &&, const Allocator &); batch_deque(std::initializer_list< T >, const Allocator & = Allocator()); batch_deque& operator=(const batch_deque &); batch_deque& operator=(batch_deque &&); batch_deque& operator=(std::initializer_list< T >); ~batch_deque(); // public member functions template<typename Iterator> void assign(Iterator, Iterator); void assign(size_type, const T &); void assign(std::initializer_list< T >); allocator_type get_allocator() const; iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; reverse_iterator rbegin(); const_reverse_iterator rbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; const_iterator cbegin() const; const_iterator cend() const; const_reverse_iterator crbegin() const; const_reverse_iterator crend() const; segment_iterator segment_begin(); const_segment_iterator segment_begin() const; segment_iterator segment_end(); const_segment_iterator segment_end() const; bool empty() const; size_type size() const; size_type max_size() const; size_type capacity() const; size_type front_free_capacity() const; size_type back_free_capacity() const; void resize(size_type); void resize(size_type, const T &); void resize_front(size_type); void resize_front(size_type, const T &); void resize_back(size_type); void resize_back(size_type, const T &); void reserve(size_type); void reserve_front(size_type); void reserve_back(size_type); void shrink_to_fit(); reference operator[](size_type); const_reference operator[](size_type) const; reference at(size_type); const_reference at(size_type) const; reference front(); const_reference front() const; reference back(); const_reference back() const; template<class... Args> void emplace_front(Args &&...); template<class... Args> void emplace_back(Args &&...); template<class... Args> iterator emplace(const_iterator, Args &&...); void push_front(const T &); void push_front(T &&); void unsafe_push_front(const T &); void unsafe_push_front(T &&); void push_back(const T &); void push_back(T &&); void unsafe_push_back(const T &); void unsafe_push_back(T &&); iterator insert(const_iterator, const T &); iterator insert(const_iterator, T &&); iterator insert(const_iterator, size_type, const T &); template<typename InputIterator> iterator insert(const_iterator, InputIterator, InputIterator); iterator insert(const_iterator, std::initializer_list< T >); template<typename InputIterator> iterator stable_insert(const_iterator, InputIterator, InputIterator); void pop_front(); void pop_back(); iterator erase(const_iterator); iterator erase(const_iterator, const_iterator); void swap(batch_deque &); void clear(); };
A standard conforming deque, providing more control over implementation details (segment size), enabling better performance in certain use-cases (see Examples).
In contrast with a standard vector, batch_deque stores the elements in multiple chunks, called segments, thus avoiding moving or copying each element upon reallocation.
Models the SequenceContainer, ReversibleContainer, and AllocatorAwareContainer concepts.
Requires:
T
shall be MoveInsertable into the batch_deque.
T
shall be Erasable from any batch_deque.
BatchDequePolicy
must model the concept with the same name.
Definition: T
is NothrowConstructible
if it's either nothrow move constructible or nothrow copy constructible.
Exceptions: The exception specifications assume T
is nothrow Destructible.
Policies:
The type BDP
models the BatchDequePolicy
concept if it satisfies the following requirements:
Expression | Return type | Description |
BDP::segment_size |
size_type |
The number of elements a segment can hold. Power of two recommended. Must be a compile time constant. |
batch_deque_policy models the BatchDequePolicy
concept.
batch_deque
public
construct/copy/destructbatch_deque();
Effects: Constructs an empty batch_deque
.
Postcondition: empty()
Complexity: Constant.
explicit batch_deque(const Allocator & allocator);
Effects: Constructs an empty batch_deque
, using the specified allocator.
Postcondition: empty()
Complexity: Constant.
explicit batch_deque(size_type n, const Allocator & allocator = Allocator());
Effects: Constructs a batch_deque
with n
default-inserted elements using the specified allocator.
Requires: T
shall be DefaultInsertable into *this
.
Postcondition: size() == n
.
Exceptions: Strong exception guarantee.
Complexity: Linear in n
.
batch_deque(size_type n, const T & value, const Allocator & allocator = Allocator());
Effects: Constructs a batch_deque
with n
copies of value
, using the specified allocator.
Requires: T
shall be CopyInsertable into *this
.
Postcondition: size() == n
.
Exceptions: Strong exception guarantee.
Complexity: Linear in n
.
template<typename InputIterator> batch_deque(InputIterator first, InputIterator last, const Allocator & allocator = Allocator());
Effects: Constructs a batch_deque
equal to the range [first,last)
, using the specified allocator.
Requires: T
shall be EmplaceConstructible into *this
from *first
. If the specified iterator does not meet the forward iterator requirements, T
shall also be MoveInsertable into *this
.
Postcondition: size() == std::distance(first, last)
Exceptions: Strong exception guarantee.
Complexity: Linear in the distance between first
and last
.
Remarks: Each iterator in the range [first,last)
shall be dereferenced exactly once, unless an exception is thrown. Although only InputIterator
is required, different optimizations are provided if first
and last
meet the requirement of ForwardIterator
or are pointers.
batch_deque(const batch_deque & rhs);
Effects: Copy constructs a batch_deque
.
Requires: T
shall be CopyInsertable into *this
.
Postcondition: this->size() == rhs.size()
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of rhs
.
batch_deque(const batch_deque & rhs, const Allocator & allocator);
Effects: Copy constructs a batch_deque
, using the specified allocator.
Requires: T
shall be CopyInsertable into *this
.
Postcondition: `this->size() == rhs.size()
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of rhs
.
batch_deque(batch_deque && rhs);
Effects: Moves rhs
's resources to *this
.
Postcondition: rhs.empty()
Complexity: Constant.
batch_deque(batch_deque && rhs, const Allocator & allocator);
Effects: Moves rhs
's resources to *this
,
Postcondition: rhs.empty()
Complexity: Constant.
batch_deque(std::initializer_list< T > il, const Allocator & allocator = Allocator());
Equivalent to:
or batch_deque
(il.begin(), il.end())
. batch_deque
(il.begin(), il.end(), allocator)
batch_deque& operator=(const batch_deque & rhs);
Effects: Copies elements of rhs
to *this
. Previously held elements get copy assigned to or destroyed.
Requires: T
shall be CopyInsertable into *this
.
Postcondition: this->size() == rhs.size()
, the elements of *this
are copies of elements in rhs
in the same order.
Returns: *this
.
Exceptions: Strong exception guarantee if T
has noexcept copy constructor and either has noexcept copy assignment operator. or the allocator is not allowed to be propagated (propagate_on_container_copy_assignment is false), Basic exception guarantee otherwise.
Complexity: Linear in the size of rhs
and *this
.
batch_deque& operator=(batch_deque && rhs);
Effects: *this
takes ownership of the resources of rhs
. The fate of the previously held elements are unspecified.
Requires: T
shall be MoveInsertable into *this
.
Postcondition: rhs
is left in an unspecified but valid state.
Returns: *this
.
Exceptions: Basic exception guarantee if not noexcept
.
Remark: If the allocator forbids propagation, the contents of rhs
is moved one-by-one instead of stealing the buffer.
Complexity: Constant, if allocator can be propagated or the two allocators compare equal, linear in the size of rhs
and *this
otherwise.
batch_deque& operator=(std::initializer_list< T > il);
Effects: Copies elements of il
to *this
. Previously held elements get copy assigned to or destroyed.
Requires: T
shall be CopyInsertable into *this
and CopyAssignable.
Postcondition: this->size() == il.size()
, the elements of *this
are copies of elements in il
in the same order.
Exceptions: Strong exception guarantee if T
is nothrow copy assignable from T
and NothrowConstructible
, Basic exception guarantee otherwise.
Returns: *this
.
Complexity: Linear in the size of il
and *this
.
~batch_deque();
Effects: Destroys the batch_deque
. All stored values are destroyed and used memory, if any, deallocated.
Complexity: Linear in the size of *this
.
batch_deque
public member functionstemplate<typename Iterator> void assign(Iterator first, Iterator last);
Effects: Replaces elements of *this
with a copy of [first,last)
. Previously held elements get copy assigned to or destroyed.
Requires: T
shall be EmplaceConstructible from *first
.
Precondition: first
and last
are not iterators into *this
.
Postcondition: size() == N
, where N
is the distance between first
and last
.
Exceptions: Strong exception guarantee if T
is nothrow copy assignable from *first
and NothrowConstructible
, Basic exception guarantee otherwise.
Complexity: Linear in the distance between first
and last
.
Remarks: Each iterator in the range [first,last)
shall be dereferenced exactly once, unless an exception is thrown.
void assign(size_type n, const T & t);
Effects: Replaces elements of *this
with n
copies of t
. Previously held elements get copy assigned to or destroyed.
Requires: T
shall be CopyInsertable into *this
and CopyAssignable.
Precondition: u
is not a reference into *this
.
Postcondition: size() == n
and the elements of *this
are copies of u
.
Exceptions: Strong exception guarantee if T
is nothrow copy assignable from u
and NothrowConstructible
, Basic exception guarantee otherwise.
Complexity: Linear in n
and the size of *this
.
void assign(std::initializer_list< T > il);
Equivalent to: assign(il.begin(), il.end())
.
allocator_type get_allocator() const;
Returns: A copy of the allocator associated with the container.
Complexity: Constant.
iterator begin();
Returns: A iterator pointing to the first element in the batch_deque
, or the past the end iterator if the batch_deque
is empty.
Complexity: Constant.
const_iterator begin() const;
Returns: A constant iterator pointing to the first element in the batch_deque
, or the past the end iterator if the batch_deque
is empty.
Complexity: Constant.
iterator end();
Returns: An iterator pointing past the last element of the container.
Complexity: Constant.
const_iterator end() const;
Returns: A constant iterator pointing past the last element of the container.
Complexity: Constant.
reverse_iterator rbegin();
Returns: A reverse iterator pointing to the first element in the reversed batch_deque
, or the reverse past the end iterator if the batch_deque
is empty.
Complexity: Constant.
const_reverse_iterator rbegin() const;
Returns: A constant reverse iterator pointing to the first element in the reversed batch_deque
, or the reverse past the end iterator if the batch_deque
is empty.
Complexity: Constant.
reverse_iterator rend();
Returns: A reverse iterator pointing past the last element in the reversed container, or to the beginning of the reversed container if it's empty.
Complexity: Constant.
const_reverse_iterator rend() const;
Returns: A constant reverse iterator pointing past the last element in the reversed container, or to the beginning of the reversed container if it's empty.
Complexity: Constant.
const_iterator cbegin() const;
Returns: A constant iterator pointing to the first element in the batch_deque
, or the past the end iterator if the batch_deque
is empty.
Complexity: Constant.
const_iterator cend() const;
Returns: A constant iterator pointing past the last element of the container.
Complexity: Constant.
const_reverse_iterator crbegin() const;
Returns: A constant reverse iterator pointing to the first element in the reversed batch_deque
, or the reverse past the end iterator if the batch_deque
is empty.
Complexity: Constant.
const_reverse_iterator crend() const;
Returns: A constant reverse iterator pointing past the last element in the reversed container, or to the beginning of the reversed container if it's empty.
Complexity: Constant.
segment_iterator segment_begin();
const_segment_iterator segment_begin() const;
segment_iterator segment_end();
const_segment_iterator segment_end() const;
bool empty() const;
Returns: True, if size() == 0
, false otherwise.
Complexity: Constant.
size_type size() const;
Returns: The number of elements the container contains.
Complexity: Constant.
size_type max_size() const;
Returns: The maximum number of elements the container could possibly hold.
Complexity: Constant.
size_type capacity() const;
Returns: The total number of elements that the batch_deque
can hold without allocating a new segment.
Complexity: Constant.
size_type front_free_capacity() const;
Returns: The total number of elements that can be pushed to the front of the sequence without requiring a new segment to be allocated.
Complexity: Constant.
size_type back_free_capacity() const;
Returns: The total number of elements that can be pushed to the back of the sequence without requiring a new segment to be allocated.
Complexity: Constant.
void resize(size_type sz);
Equivalent to: resize_back(sz)
void resize(size_type sz, const T & c);
Equivalent to: resize_back(sz, c)
void resize_front(size_type sz);
Effects: If sz
is greater than the size of *this
, additional value-initialized elements are inserted to the front. Invalidates iterators if segment allocation is needed. If sz
is smaller than than the size of *this
, elements are popped from the front.
Requires: T shall be DefaultConstructible.
Postcondition: sz == size()
.
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of *this
and sz
.
void resize_front(size_type sz, const T & c);
Effects: If sz
is greater than the size of *this
, copies of c
are inserted to the front. Invalidates iterators if segment allocation is needed. If sz
is smaller than than the size of *this
, elements are popped from the front.
Postcondition: sz == size()
.
Requires: T
shall be CopyInsertable into *this
.
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of *this
and sz
.
void resize_back(size_type sz);
Effects: If sz
is greater than the size of *this
, additional value-initialized elements are inserted to the back. Invalidates iterators if segment allocation is needed. If sz
is smaller than than the size of *this
, elements are popped from the back.
Requires: T shall be DefaultConstructible.
Postcondition: sz == size()
.
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of *this
and sz
.
void resize_back(size_type sz, const T & c);
Effects: If sz
is greater than the size of *this
, copies of c
are inserted to the back. Invalidates iterators if segment allocation is needed. If sz
is smaller than than the size of *this
, elements are popped from the back.
Postcondition: sz == size()
.
Requires: T
shall be CopyInsertable into *this
.
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of *this
and sz
.
void reserve(size_type new_capacity);
Equivalent to: reserve_back(new_capacity)
void reserve_front(size_type new_capacity);
Effects: Ensures that n
elements can be pushed to the front without requiring a segment to be allocated, where n
is new_capacity - size()
, if n
is positive. Otherwise, there are no effects.
Complexity: Linear in new_capacity / segment_size
.
Exceptions: Strong exception guarantee.
Remark: Establishes the precondition of n
subsequent unsafe_push_front
calls.
void reserve_back(size_type new_capacity);
Effects: Ensures that n
elements can be pushed to the back without requiring a segment to be allocated, where n
is new_capacity - size()
, if n
is positive. Otherwise, there are no effects.
Complexity: Linear in new_capacity / segment_size
.
Exceptions: Strong exception guarantee.
Remark: Establishes the precondition of n
subsequent unsafe_push_back
calls.
void shrink_to_fit();
Effects: Deallocates empty segments.
Complexity: Linear in the number of segments.
reference operator[](size_type n);
Returns: A reference to the n
th element in the container.
Precondition: n < size()
.
Complexity: Constant.
const_reference operator[](size_type n) const;
Returns: A constant reference to the n
th element in the container.
Precondition: n < size()
.
Complexity: Constant.
reference at(size_type n);
Returns: A reference to the n
th element in the container.
Throws: std::out_of_range
, if n >= size()
.
Complexity: Constant.
const_reference at(size_type n) const;
Returns: A constant reference to the n
th element in the batch_deque
.
Throws: std::out_of_range
, if n >= size()
.
Complexity: Constant.
reference front();
Returns: A reference to the first element in the batch_deque
.
Precondition: !empty()
.
Complexity: Constant.
const_reference front() const;
Returns: A constant reference to the first element in the batch_deque
.
Precondition: !empty()
.
Complexity: Constant.
reference back();
Returns: A reference to the last element in the batch_deque
.
Precondition: !empty()
.
Complexity: Constant.
const_reference back() const;
Returns: A constant reference to the last element in the batch_deque
.
Precondition: !empty()
.
Complexity: Constant.
template<class... Args> void emplace_front(Args &&... args);
Effects: Constructs a new element at the front of the sequence. The element is constructed in-place, using the perfect forwarded args
as constructor arguments. Invalidates iterators.
Requires: T
shall be EmplaceConstructible from args
.
Exceptions: Strong exception guarantee.
Complexity: Amortized constant.
template<class... Args> void emplace_back(Args &&... args);
Effects: Constructs a new element at the back of the sequence. The element is constructed in-place, using the perfect forwarded args
as constructor arguments. Invalidates iterators.
Requires: T
shall be EmplaceConstructible from args
.
Exceptions: Strong exception guarantee.
Complexity: Amortized constant.
template<class... Args> iterator emplace(const_iterator position, Args &&... args);
Effects: Constructs a new element before the element pointed by position
. The element is constructed in-place, using the perfect forwarded args
as constructor arguments. Invalidates iterators.
Requires: T
shall be EmplaceConstructible from args
and MoveAssignable
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of *this
.
void push_front(const T & x);
Effects: Pushes the copy of x
to the front of the sequence. Invalidates iterators.
Requires: T
shall be CopyInsertable into *this
.
Exceptions: Strong exception guarantee.
Complexity: Amortized constant.
void push_front(T && x);
Effects: Move constructs a new element at the front of the sequence using x
. Invalidates iterators.
Requires: T
shall be MoveInsertable into *this
.
Exceptions: Strong exception guarantee, not regarding the state of x
.
Complexity: Amortized constant.
void unsafe_push_front(const T & x);
Effects: Pushes the copy of x
to the front of the sequence.
Requires: T
shall be CopyInsertable into *this
.
Precondition: front_free_capacity() > 0
.
Postcondition: size()
is incremented by 1, front_free_capacity() is decremented by 1
Exceptions: Strong exception guarantee.
Complexity: Constant.
void unsafe_push_front(T && x);
Effects: Move constructs a new element at the front of the sequence using x
.
Requires: T
shall be MoveInsertable into *this
.
Precondition: front_free_capacity() > 0
.
Postcondition: size()
is incremented by 1, front_free_capacity() is decremented by 1
Exceptions: Strong exception guarantee, not regarding the state of x
.
Complexity: Constant.
void push_back(const T & x);
Effects: Pushes the copy of x
to the back of the sequence. Invalidates iterators.
Requires: T
shall be CopyInsertable into *this
.
Exceptions: Strong exception guarantee.
Complexity: Amortized constant.
void push_back(T && x);
Effects: Move constructs a new element at the back of the sequence using x
. Invalidates iterators.
Requires: T
shall be MoveInsertable into *this
.
Exceptions: Strong exception guarantee, not regarding the state of x
.
Complexity: Amortized constant.
void unsafe_push_back(const T & x);
Effects: Pushes the copy of x
to the back of the sequence.
Requires: T
shall be CopyInsertable into *this
.
Precondition: back_free_capacity() > 0
.
Postcondition: size()
is incremented by 1, back_free_capacity() is decremented by 1
Exceptions: Strong exception guarantee.
Complexity: Constant.
void unsafe_push_back(T && x);
Effects: Move constructs a new element at the back of the sequence using x
.
Requires: T
shall be MoveInsertable into *this
.
Precondition: back_free_capacity() > 0
.
Postcondition: size()
is incremented by 1, back_free_capacity() is decremented by 1
Exceptions: Strong exception guarantee, not regarding the state of x
.
Complexity: Constant.
iterator insert(const_iterator position, const T & x);
Effects: Copy constructs a new element before the element pointed by position
, using x
as constructor argument. Invalidates iterators.
Requires: T
shall be CopyInsertable into *this
and and CopyAssignable.
Returns: Iterator pointing to the newly constructed element.
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of *this
.
iterator insert(const_iterator position, T && x);
Effects: Move constructs a new element before the element pointed by position
, using x
as constructor argument. Invalidates iterators.
Requires: T
shall be MoveInsertable into *this
and and MoveAssignable.
Returns: Iterator pointing to the newly constructed element.
Exceptions: Strong exception guarantee.
Complexity: Linear in the size of *this
.
iterator insert(const_iterator position, size_type n, const T & x);
Effects: Copy constructs n
elements before the element pointed by position
, using x
as constructor argument. Invalidates iterators.
Requires: T
shall be CopyInsertable into *this
and MoveAssignable.
Returns: Iterator pointing to the first inserted element, or position
, if n
is zero.
Exceptions: Strong exception guarantee if T
is NothrowConstructible
and NothrowAssignable
, Basic exception guarantee otherwise.
Complexity: Linear in the size of *this
and n
.
template<typename InputIterator> iterator insert(const_iterator position, InputIterator first, InputIterator last);
Effects: Copy constructs elements before the element pointed by position
using each element in the rage pointed by first
and last
as constructor arguments. Invalidates iterators.
Requires: T
shall be EmplaceConstructible into *this
from *first
, MoveAssignable and MoveConstructible.
Precondition: first
and last
are not iterators into *this
.
Returns: Iterator pointing to the first inserted element, or position
, if first == last
.
Complexity: Linear in the size of *this
and in the distance between first
and last
.
Exceptions: Strong exception guarantee if T
is NothrowConstructible
and NothrowAssignable
, Basic exception guarantee otherwise.
Remarks: Each iterator in the range [first,last)
shall be dereferenced exactly once, unless an exception is thrown.
iterator insert(const_iterator position, std::initializer_list< T > il);
Equivalent to: insert(position, il.begin(), il.end())
template<typename InputIterator> iterator stable_insert(const_iterator position_hint, InputIterator first, InputIterator last);
Effects: Copy constructs elements at the nearest segment boundary before position_hint
using each element in the range [first, last)
as constructor arguments without invalidating any iterators or references. If necessary, inserts default constructed elements to avoid a gap in the newly created segment.
Requires: T
shall be EmplaceConstructible into *this
from *first
, MoveAssignable, MoveConstructible and DefaultConstructible.
Precondition: first
and last
are not iterators into *this
.
Returns: Iterator pointing to the first inserted element, or position
, if first == last
.
Complexity: Linear in the size of *this
and in the distance between first
and last
.
Exceptions: Strong exception guarantee if T
is NothrowConstructible
and NothrowAssignable
, Basic exception guarantee otherwise.
Remarks: Each iterator in the range [first,last)
shall be dereferenced exactly once, unless an exception is thrown.
void pop_front();
Effects: Removes the first element of *this
.
Precondition: !empty()
.
Complexity: Constant.
void pop_back();
Effects: Removes the last element of *this
.
Precondition: !empty()
.
Complexity: Constant.
iterator erase(const_iterator position);
Effects: Destroys the element pointed by position
and removes it from the sequence. Invalidates iterators.
Requires: T
shall be MoveAssignable.
Precondition: position
must be in the range of [begin(), end())
.
Returns: Iterator pointing to the element immediately following the erased element prior to its erasure. If no such element exists, end()
is returned.
Exceptions: Strong exception guarantee if T
is NothrowAssignable
, Basic exception guarantee otherwise.
Complexity: Linear in the size of *this
.
iterator erase(const_iterator first, const_iterator last);
Effects: Destroys the range [first,last)
and removes it from the sequence. Invalidates iterators.
Requires: T
shall be MoveAssignable.
Precondition: [first,last)
must be in the range of [begin(), end())
.
Returns: Iterator pointing to the element pointed to by last
prior to any elements being erased. If no such element exists, end()
is returned.
Exceptions: Strong exception guarantee if T
is NothrowAssignable
, Basic exception guarantee otherwise.
Complexity: Linear in the size of *this
plus the distance between first
and last
.
void swap(batch_deque & rhs);
Effects: exchanges the contents of *this
with those of rhs
. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid.
Precondition: The allocators should allow propagation or should compare equal.
Complexity: Constant.
void clear();
Effects: Destroys all elements in the sequence. Invalidates all references, pointers and iterators.
Postcondition: empty()
.
Complexity: Linear in the size of *this
.
Remark: Doesn't deallocate segments. Call shrink_to_fit
if segments must be released.