mirror of
https://github.com/boostorg/container.git
synced 2025-08-03 06:24:26 +02:00
Trailing whitespaces
[SVN r78518]
This commit is contained in:
@@ -378,6 +378,14 @@ class flat_tree
|
||||
this->priv_insert_equal(ordered_range_t(), first, last, ItCat());
|
||||
}
|
||||
|
||||
template <class InIt>
|
||||
void insert_unique(ordered_unique_range_t, InIt first, InIt last)
|
||||
{
|
||||
typedef typename
|
||||
std::iterator_traits<InIt>::iterator_category ItCat;
|
||||
this->priv_insert_unique(ordered_unique_range_t(), first, last, ItCat());
|
||||
}
|
||||
|
||||
#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
|
||||
|
||||
template <class... Args>
|
||||
@@ -801,28 +809,82 @@ class flat_tree
|
||||
const size_type BurstSize = 16;
|
||||
size_type positions[BurstSize];
|
||||
|
||||
//Prereserve all memory so that iterators are not invalidated
|
||||
this->reserve(this->size()+len);
|
||||
const const_iterator beg(this->cbegin());
|
||||
const_iterator pos(beg);
|
||||
//Loop in burst sizes
|
||||
while(len){
|
||||
const size_type burst = len < BurstSize ? len : BurstSize;
|
||||
const const_iterator cend(this->cend());
|
||||
len -= burst;
|
||||
const iterator beg(this->cbegin());
|
||||
iterator pos;
|
||||
for(size_type i = 0; i != burst; ++i){
|
||||
pos = this->upper_bound(KeyOfValue()(*first));
|
||||
//Get the insertion position for each key
|
||||
pos = const_cast<const flat_tree&>(*this).priv_upper_bound(pos, cend, KeyOfValue()(*first));
|
||||
positions[i] = static_cast<size_type>(pos - beg);
|
||||
++first;
|
||||
}
|
||||
//Insert all in a single step in the precalculated positions
|
||||
this->m_data.m_vect.insert_ordered_at(burst, positions + burst, first);
|
||||
//Next search position updated
|
||||
pos += burst;
|
||||
}
|
||||
}
|
||||
|
||||
template <class BidirIt>
|
||||
void priv_insert_unique(ordered_unique_range_t, BidirIt first, BidirIt last, std::bidirectional_iterator_tag)
|
||||
{
|
||||
size_type len = static_cast<size_type>(std::distance(first, last));
|
||||
const size_type BurstSize = 16;
|
||||
size_type positions[BurstSize];
|
||||
size_type skips[BurstSize];
|
||||
|
||||
//Prereserve all memory so that iterators are not invalidated
|
||||
this->reserve(this->size()+len);
|
||||
const const_iterator beg(this->cbegin());
|
||||
const_iterator pos(beg);
|
||||
const value_compare &value_comp = this->m_data;
|
||||
//Loop in burst sizes
|
||||
while(len){
|
||||
skips[0u] = 0u;
|
||||
const size_type burst = len < BurstSize ? len : BurstSize;
|
||||
size_type unique_burst = 0u;
|
||||
const const_iterator cend(this->cend());
|
||||
while(unique_burst < burst && len > 0){
|
||||
//Get the insertion position for each key
|
||||
const value_type & val = *first++;
|
||||
--len;
|
||||
pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, cend, KeyOfValue()(val));
|
||||
//Check if already present
|
||||
if(pos != cend && !value_comp(*pos, val)){
|
||||
++skips[unique_burst];
|
||||
continue;
|
||||
}
|
||||
|
||||
//If not present, calculate position
|
||||
positions[unique_burst] = static_cast<size_type>(pos - beg);
|
||||
if(++unique_burst < burst)
|
||||
skips[unique_burst] = 0u;
|
||||
}
|
||||
//Insert all in a single step in the precalculated positions
|
||||
this->m_data.m_vect.insert_ordered_at(unique_burst, positions + unique_burst, skips + unique_burst, first);
|
||||
//Next search position updated
|
||||
pos += unique_burst;
|
||||
}
|
||||
}
|
||||
/*
|
||||
template <class FwdIt>
|
||||
void priv_insert_equal_forward(ordered_range_t, FwdIt first, FwdIt last, std::forward_iterator_tag)
|
||||
{ this->priv_insert_equal(first, last, std::forward_iterator_tag()); }
|
||||
|
||||
*/
|
||||
template <class InIt>
|
||||
void priv_insert_equal(ordered_range_t, InIt first, InIt last, std::input_iterator_tag)
|
||||
{ this->priv_insert_equal(first, last, std::input_iterator_tag()); }
|
||||
|
||||
template <class InIt>
|
||||
void priv_insert_unique(ordered_unique_range_t, InIt first, InIt last, std::input_iterator_tag)
|
||||
{ this->priv_insert_unique(first, last, std::input_iterator_tag()); }
|
||||
/*
|
||||
template <class FwdIt>
|
||||
void priv_insert_equal_forward(FwdIt first, FwdIt last, std::forward_iterator_tag)
|
||||
{
|
||||
@@ -830,7 +892,7 @@ class flat_tree
|
||||
this->reserve(this->size()+len);
|
||||
this->priv_insert_equal(first, last, std::input_iterator_tag());
|
||||
}
|
||||
|
||||
*/
|
||||
template <class InIt>
|
||||
void priv_insert_equal(InIt first, InIt last, std::input_iterator_tag)
|
||||
{
|
||||
|
@@ -205,6 +205,8 @@ class flat_map
|
||||
//! unique values.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear in N.
|
||||
//!
|
||||
//! <b>Note</b>: Non-standard extension.
|
||||
template <class InputIterator>
|
||||
flat_map( ordered_unique_range_t, InputIterator first, InputIterator last
|
||||
, const Pred& comp = Pred(), const allocator_type& a = allocator_type())
|
||||
@@ -569,6 +571,23 @@ class flat_map
|
||||
void insert(InputIterator first, InputIterator last)
|
||||
{ m_flat_tree.insert_unique(first, last); }
|
||||
|
||||
//! <b>Requires</b>: first, last are not iterators into *this.
|
||||
//!
|
||||
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
|
||||
//! unique values.
|
||||
//!
|
||||
//! <b>Effects</b>: inserts each element from the range [first,last) if and only
|
||||
//! if there is no element with key equivalent to the key of that element. This
|
||||
//! function is more efficient than the normal range creation for ordered ranges.
|
||||
//!
|
||||
//! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
|
||||
//! search time plus N*size() insertion time.
|
||||
//!
|
||||
//! <b>Note</b>: If an element is inserted it might invalidate elements.
|
||||
template <class InputIterator>
|
||||
void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
|
||||
{ m_flat_tree.insert_unique(ordered_unique_range, first, last); }
|
||||
|
||||
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
|
||||
//! <b>Effects</b>: Inserts an object x of type T constructed with
|
||||
@@ -975,6 +994,8 @@ class flat_multimap
|
||||
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear in N.
|
||||
//!
|
||||
//! <b>Note</b>: Non-standard extension.
|
||||
template <class InputIterator>
|
||||
flat_multimap(ordered_range_t, InputIterator first, InputIterator last,
|
||||
const Pred& comp = Pred(),
|
||||
@@ -1277,6 +1298,22 @@ class flat_multimap
|
||||
void insert(InputIterator first, InputIterator last)
|
||||
{ m_flat_tree.insert_equal(first, last); }
|
||||
|
||||
//! <b>Requires</b>: first, last are not iterators into *this.
|
||||
//!
|
||||
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
|
||||
//!
|
||||
//! <b>Effects</b>: inserts each element from the range [first,last) if and only
|
||||
//! if there is no element with key equivalent to the key of that element. This
|
||||
//! function is more efficient than the normal range creation for ordered ranges.
|
||||
//!
|
||||
//! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
|
||||
//! search time plus N*size() insertion time.
|
||||
//!
|
||||
//! <b>Note</b>: If an element is inserted it might invalidate elements.
|
||||
template <class InputIterator>
|
||||
void insert(ordered_range_t, InputIterator first, InputIterator last)
|
||||
{ m_flat_tree.insert_equal(ordered_range, first, last); }
|
||||
|
||||
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
|
||||
//! <b>Effects</b>: Inserts an object of type T constructed with
|
||||
|
@@ -136,6 +136,8 @@ class flat_set
|
||||
//! unique values.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear in N.
|
||||
//!
|
||||
//! <b>Note</b>: Non-standard extension.
|
||||
template <class InputIterator>
|
||||
flat_set(ordered_unique_range_t, InputIterator first, InputIterator last,
|
||||
const Pred& comp = Pred(),
|
||||
@@ -432,6 +434,21 @@ class flat_set
|
||||
void insert(InputIterator first, InputIterator last)
|
||||
{ m_flat_tree.insert_unique(first, last); }
|
||||
|
||||
//! <b>Requires</b>: first, last are not iterators into *this and
|
||||
//! must be ordered according to the predicate and must be
|
||||
//! unique values.
|
||||
//!
|
||||
//! <b>Effects</b>: inserts each element from the range [first,last) .This function
|
||||
//! is more efficient than the normal range creation for ordered ranges.
|
||||
//!
|
||||
//! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
|
||||
//! search time plus N*size() insertion time.
|
||||
//!
|
||||
//! <b>Note</b>: Non-standard extension. If an element is inserted it might invalidate elements.
|
||||
template <class InputIterator>
|
||||
void insert(ordered_unique_range_t, InputIterator first, InputIterator last)
|
||||
{ m_flat_tree.insert_unique(ordered_unique_range, first, last); }
|
||||
|
||||
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
|
||||
//! <b>Effects</b>: Inserts an object x of type T constructed with
|
||||
@@ -770,6 +787,8 @@ class flat_multiset
|
||||
//! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
|
||||
//!
|
||||
//! <b>Complexity</b>: Linear in N.
|
||||
//!
|
||||
//! <b>Note</b>: Non-standard extension.
|
||||
template <class InputIterator>
|
||||
flat_multiset(ordered_range_t, InputIterator first, InputIterator last,
|
||||
const Pred& comp = Pred(),
|
||||
@@ -1058,6 +1077,20 @@ class flat_multiset
|
||||
void insert(InputIterator first, InputIterator last)
|
||||
{ m_flat_tree.insert_equal(first, last); }
|
||||
|
||||
//! <b>Requires</b>: first, last are not iterators into *this and
|
||||
//! must be ordered according to the predicate.
|
||||
//!
|
||||
//! <b>Effects</b>: inserts each element from the range [first,last) .This function
|
||||
//! is more efficient than the normal range creation for ordered ranges.
|
||||
//!
|
||||
//! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
|
||||
//! search time plus N*size() insertion time.
|
||||
//!
|
||||
//! <b>Note</b>: Non-standard extension. If an element is inserted it might invalidate elements.
|
||||
template <class InputIterator>
|
||||
void insert(ordered_range_t, InputIterator first, InputIterator last)
|
||||
{ m_flat_tree.insert_equal(ordered_range, first, last); }
|
||||
|
||||
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||
|
||||
//! <b>Effects</b>: Inserts an object of type T constructed with
|
||||
|
@@ -1288,6 +1288,21 @@ class vector : private container_detail::vector_alloc_holder<A>
|
||||
|
||||
/// @cond
|
||||
|
||||
//Absolutely experimental. This function might change, disappear or simply crash!
|
||||
template<class BiDirPosConstIt, class BiDirValueIt>
|
||||
void insert_ordered_at(size_type element_count, BiDirPosConstIt last_position_it, BiDirValueIt last_value_it)
|
||||
{
|
||||
const size_type *dummy = 0;
|
||||
this->priv_insert_ordered_at(element_count, last_position_it, false, &dummy[0], last_value_it);
|
||||
}
|
||||
|
||||
//Absolutely experimental. This function might change, disappear or simply crash!
|
||||
template<class BiDirPosConstIt, class BiDirSkipConstIt, class BiDirValueIt>
|
||||
void insert_ordered_at(size_type element_count, BiDirPosConstIt last_position_it, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it)
|
||||
{
|
||||
this->priv_insert_ordered_at(element_count, last_position_it, true, last_skip_it, last_value_it);
|
||||
}
|
||||
|
||||
private:
|
||||
iterator priv_insert(const_iterator position, const T &x)
|
||||
{
|
||||
@@ -1463,10 +1478,10 @@ class vector : private container_detail::vector_alloc_holder<A>
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
//Absolutely experimental. This function might change, disappear or simply crash!
|
||||
template<class BiDirPosIt, class BiDirValueIt>
|
||||
void insert_ordered_at(size_type element_count, BiDirPosIt last_position_it, BiDirValueIt last_value_it)
|
||||
template<class BiDirPosConstIt, class BiDirSkipConstIt, class BiDirValueIt>
|
||||
void priv_insert_ordered_at( size_type element_count, BiDirPosConstIt last_position_it
|
||||
, bool do_skip, BiDirSkipConstIt last_skip_it, BiDirValueIt last_value_it)
|
||||
{
|
||||
const size_type old_size_pos = this->size();
|
||||
this->reserve(old_size_pos + element_count);
|
||||
@@ -1484,11 +1499,15 @@ class vector : private container_detail::vector_alloc_holder<A>
|
||||
while(insertions_left){
|
||||
const size_type pos = static_cast<size_type>(*(--last_position_it));
|
||||
BOOST_ASSERT(pos <= old_size_pos);
|
||||
//Shift the range after the insertion point, function will take care if the shift
|
||||
//crosses the size() boundary, using copy/move or uninitialized copy/move if necessary.
|
||||
size_type new_hole_size = insert_ordered_at_shift_range(pos, next_pos, this->size(), insertions_left);
|
||||
//If needed shift the range after the insertion point and the previous insertion point.
|
||||
//Function will take care if the shift crosses the size() boundary, using copy/move
|
||||
//or uninitialized copy/move if necessary.
|
||||
size_type new_hole_size = (pos != next_pos)
|
||||
? priv_insert_ordered_at_shift_range(pos, next_pos, this->size(), insertions_left)
|
||||
: hole_size
|
||||
;
|
||||
if(new_hole_size > 0){
|
||||
//The hole was reduced by insert_ordered_at_shift_range so expand exception rollback range backwards
|
||||
//The hole was reduced by priv_insert_ordered_at_shift_range so expand exception rollback range backwards
|
||||
past_hole_values_destroyer.increment_size_backwards(next_pos - pos);
|
||||
//Insert the new value in the hole
|
||||
allocator_traits_type::construct(this->alloc(), begin_ptr + pos + insertions_left - 1, *(--last_value_it));
|
||||
@@ -1505,13 +1524,19 @@ class vector : private container_detail::vector_alloc_holder<A>
|
||||
}
|
||||
else{
|
||||
if(hole_size){
|
||||
//Hole was just filled by insert_ordered_at_shift_range, disable exception rollback and change vector size
|
||||
//Hole was just filled by priv_insert_ordered_at_shift_range, disable exception rollback and change vector size
|
||||
past_hole_values_destroyer.release();
|
||||
this->members_.m_size += element_count;
|
||||
}
|
||||
//Insert the new value in the already constructed range
|
||||
begin_ptr[pos + insertions_left - 1] = *(--last_value_it);
|
||||
}
|
||||
if(do_skip){
|
||||
size_type n = *(--last_skip_it);
|
||||
while(n--){
|
||||
--last_value_it;
|
||||
}
|
||||
}
|
||||
--insertions_left;
|
||||
hole_size = new_hole_size;
|
||||
next_pos = pos;
|
||||
@@ -1569,7 +1594,7 @@ class vector : private container_detail::vector_alloc_holder<A>
|
||||
//|___________________________________|___^___|
|
||||
// | |
|
||||
// |_>_>_>_>_>_>_>_>_>_>_>^
|
||||
size_type insert_ordered_at_shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
|
||||
size_type priv_insert_ordered_at_shift_range(size_type first_pos, size_type last_pos, size_type limit_pos, size_type shift_count)
|
||||
{
|
||||
BOOST_ASSERT(first_pos <= last_pos);
|
||||
BOOST_ASSERT(last_pos <= limit_pos);
|
||||
@@ -1597,7 +1622,7 @@ class vector : private container_detail::vector_alloc_holder<A>
|
||||
::boost::container::uninitialized_move_alloc
|
||||
(this->alloc(), boundary_ptr, begin_ptr + last_pos, limit_ptr);
|
||||
//The rest is move assigned
|
||||
boost::move_backward(begin_ptr + first_pos, boundary_ptr, limit_ptr + shift_count);
|
||||
boost::move_backward(begin_ptr + first_pos, boundary_ptr, limit_ptr);
|
||||
}
|
||||
return hole_size;
|
||||
}
|
||||
|
Reference in New Issue
Block a user