mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 14:04:26 +02:00
Derived flat_set from flat_tree to avoid redefining almost all functions and minimize instantiation of multiple function in debug mode.
This commit is contained in:
@@ -270,6 +270,9 @@ class flat_tree
|
|||||||
Compare key_comp() const
|
Compare key_comp() const
|
||||||
{ return this->m_data.get_comp(); }
|
{ return this->m_data.get_comp(); }
|
||||||
|
|
||||||
|
value_compare value_comp() const
|
||||||
|
{ return this->m_data; }
|
||||||
|
|
||||||
allocator_type get_allocator() const
|
allocator_type get_allocator() const
|
||||||
{ return this->m_data.m_vect.get_allocator(); }
|
{ return this->m_data.m_vect.get_allocator(); }
|
||||||
|
|
||||||
@@ -526,7 +529,7 @@ class flat_tree
|
|||||||
this->reserve(this->size()+len);
|
this->reserve(this->size()+len);
|
||||||
const const_iterator b(this->cbegin());
|
const const_iterator b(this->cbegin());
|
||||||
const_iterator pos(b);
|
const_iterator pos(b);
|
||||||
const value_compare &value_comp = this->m_data;
|
const value_compare &val_cmp = this->m_data;
|
||||||
skips[0u] = 0u;
|
skips[0u] = 0u;
|
||||||
//Loop in burst sizes
|
//Loop in burst sizes
|
||||||
while(len){
|
while(len){
|
||||||
@@ -539,7 +542,7 @@ class flat_tree
|
|||||||
--len;
|
--len;
|
||||||
pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, ce, KeyOfValue()(val));
|
pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, ce, KeyOfValue()(val));
|
||||||
//Check if already present
|
//Check if already present
|
||||||
if(pos != ce && !value_comp(val, *pos)){
|
if(pos != ce && !val_cmp(val, *pos)){
|
||||||
if(unique_burst > 0){
|
if(unique_burst > 0){
|
||||||
++skips[unique_burst-1];
|
++skips[unique_burst-1];
|
||||||
}
|
}
|
||||||
@@ -790,10 +793,10 @@ class flat_tree
|
|||||||
// insert val before upper_bound(val)
|
// insert val before upper_bound(val)
|
||||||
// else
|
// else
|
||||||
// insert val before lower_bound(val)
|
// insert val before lower_bound(val)
|
||||||
const value_compare &value_comp = this->m_data;
|
const value_compare &val_cmp = this->m_data;
|
||||||
|
|
||||||
if(pos == this->cend() || !value_comp(*pos, val)){
|
if(pos == this->cend() || !val_cmp(*pos, val)){
|
||||||
if (pos == this->cbegin() || !value_comp(val, pos[-1])){
|
if (pos == this->cbegin() || !val_cmp(val, pos[-1])){
|
||||||
data.position = pos;
|
data.position = pos;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -810,9 +813,9 @@ class flat_tree
|
|||||||
bool priv_insert_unique_prepare
|
bool priv_insert_unique_prepare
|
||||||
(const_iterator b, const_iterator e, const value_type& val, insert_commit_data &commit_data)
|
(const_iterator b, const_iterator e, const value_type& val, insert_commit_data &commit_data)
|
||||||
{
|
{
|
||||||
const value_compare &value_comp = this->m_data;
|
const value_compare &val_cmp = this->m_data;
|
||||||
commit_data.position = this->priv_lower_bound(b, e, KeyOfValue()(val));
|
commit_data.position = this->priv_lower_bound(b, e, KeyOfValue()(val));
|
||||||
return commit_data.position == e || value_comp(val, *commit_data.position);
|
return commit_data.position == e || val_cmp(val, *commit_data.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool priv_insert_unique_prepare
|
bool priv_insert_unique_prepare
|
||||||
@@ -833,9 +836,9 @@ class flat_tree
|
|||||||
// insert val after pos
|
// insert val after pos
|
||||||
//else
|
//else
|
||||||
// insert val before lower_bound(val)
|
// insert val before lower_bound(val)
|
||||||
const value_compare &value_comp = this->m_data;
|
const value_compare &val_cmp = this->m_data;
|
||||||
const const_iterator cend_it = this->cend();
|
const const_iterator cend_it = this->cend();
|
||||||
if(pos == cend_it || value_comp(val, *pos)){ //Check if val should go before end
|
if(pos == cend_it || val_cmp(val, *pos)){ //Check if val should go before end
|
||||||
const const_iterator cbeg = this->cbegin();
|
const const_iterator cbeg = this->cbegin();
|
||||||
commit_data.position = pos;
|
commit_data.position = pos;
|
||||||
if(pos == cbeg){ //If container is empty then insert it in the beginning
|
if(pos == cbeg){ //If container is empty then insert it in the beginning
|
||||||
@@ -843,10 +846,10 @@ class flat_tree
|
|||||||
}
|
}
|
||||||
const_iterator prev(pos);
|
const_iterator prev(pos);
|
||||||
--prev;
|
--prev;
|
||||||
if(value_comp(*prev, val)){ //If previous element was less, then it should go between prev and pos
|
if(val_cmp(*prev, val)){ //If previous element was less, then it should go between prev and pos
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(!value_comp(val, *prev)){ //If previous was equal then insertion should fail
|
else if(!val_cmp(val, *prev)){ //If previous was equal then insertion should fail
|
||||||
commit_data.position = prev;
|
commit_data.position = prev;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -105,6 +105,59 @@ template class flat_multiset
|
|||||||
, node_allocator<test::movable_and_copyable_int>
|
, node_allocator<test::movable_and_copyable_int>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
namespace container_detail {
|
||||||
|
|
||||||
|
//Instantiate base class as previous instantiations don't instantiate inherited members
|
||||||
|
template class flat_tree
|
||||||
|
< test::movable_and_copyable_int
|
||||||
|
, test::movable_and_copyable_int
|
||||||
|
, identity<test::movable_and_copyable_int>
|
||||||
|
, std::less<test::movable_and_copyable_int>
|
||||||
|
, test::dummy_test_allocator<test::movable_and_copyable_int>
|
||||||
|
>;
|
||||||
|
|
||||||
|
template class flat_tree
|
||||||
|
< test::movable_and_copyable_int
|
||||||
|
, test::movable_and_copyable_int
|
||||||
|
, identity<test::movable_and_copyable_int>
|
||||||
|
, std::less<test::movable_and_copyable_int>
|
||||||
|
, test::simple_allocator<test::movable_and_copyable_int>
|
||||||
|
>;
|
||||||
|
|
||||||
|
template class flat_tree
|
||||||
|
< test::movable_and_copyable_int
|
||||||
|
, test::movable_and_copyable_int
|
||||||
|
, identity<test::movable_and_copyable_int>
|
||||||
|
, std::less<test::movable_and_copyable_int>
|
||||||
|
, std::allocator<test::movable_and_copyable_int>
|
||||||
|
>;
|
||||||
|
|
||||||
|
template class flat_tree
|
||||||
|
< test::movable_and_copyable_int
|
||||||
|
, test::movable_and_copyable_int
|
||||||
|
, identity<test::movable_and_copyable_int>
|
||||||
|
, std::less<test::movable_and_copyable_int>
|
||||||
|
, allocator<test::movable_and_copyable_int>
|
||||||
|
>;
|
||||||
|
|
||||||
|
template class flat_tree
|
||||||
|
< test::movable_and_copyable_int
|
||||||
|
, test::movable_and_copyable_int
|
||||||
|
, identity<test::movable_and_copyable_int>
|
||||||
|
, std::less<test::movable_and_copyable_int>
|
||||||
|
, adaptive_pool<test::movable_and_copyable_int>
|
||||||
|
>;
|
||||||
|
|
||||||
|
template class flat_tree
|
||||||
|
< test::movable_and_copyable_int
|
||||||
|
, test::movable_and_copyable_int
|
||||||
|
, identity<test::movable_and_copyable_int>
|
||||||
|
, std::less<test::movable_and_copyable_int>
|
||||||
|
, node_allocator<test::movable_and_copyable_int>
|
||||||
|
>;
|
||||||
|
|
||||||
|
} //container_detail {
|
||||||
|
|
||||||
//As flat container iterators are typedefs for vector::[const_]iterator,
|
//As flat container iterators are typedefs for vector::[const_]iterator,
|
||||||
//no need to explicit instantiate them
|
//no need to explicit instantiate them
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user