Add improved range insertion to flat associative containers and improve merge operation for vector.

This commit is contained in:
Ion Gaztañaga
2017-12-26 22:04:15 +01:00
parent 3c6f4ea2ed
commit 6ce2b2d0f8
8 changed files with 309 additions and 274 deletions
+19
View File
@@ -316,6 +316,25 @@ bool flat_tree_ordered_insertion_test()
int_set4.insert(int_even_set.begin(), int_even_set.end());
if(!CheckEqualContainers(int_set4, fset))
return false;
//add even/odd values with not enough capacity
flat_set<int>().swap(fset);
int_set4.clear();
int_set.clear();
fset.reserve(int_even_set.size());
fset.insert(ordered_unique_range, int_even_set.begin(), int_even_set.end());
int_set4.insert(int_even_set.begin(), int_even_set.end());
for(std::size_t i = 0; i < NumElements*2; i+=2){
int_set.insert(static_cast<int>(i));
int_set.insert(static_cast<int>(i+1));
}
fset.insert(ordered_unique_range, int_set.begin(), int_set.end());
int_set4.insert(int_set.begin(), int_set.end());
if(!CheckEqualContainers(int_set4, fset))
return false;
}
return true;
+9 -9
View File
@@ -388,12 +388,12 @@ int set_test ()
boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect[0])..." << std::endl;
std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl;
return 1;
}
boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), ..." << std::endl;
return 1;
@@ -447,14 +447,14 @@ int set_test ()
boostset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + 50));
stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
boostmultiset.insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(&aux_vect4[0] + 50));
boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(&aux_vect5[0] + 50));
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl;
return 1;
}
boostmultiset.insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(&aux_vect4[0] + 50));
boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(&aux_vect5[0] + 50));
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0])..." << std::endl;
return 1;
@@ -462,12 +462,12 @@ int set_test ()
boostset.erase(*boostset.begin());
stdset.erase(*stdset.begin());
boostmultiset.erase(*boostmultiset.begin());
stdmultiset.erase(*stdmultiset.begin());
if(!CheckEqualContainers(boostset, stdset)){
std::cout << "Error in boostset.erase(*boostset.begin())" << std::endl;
return 1;
}
boostmultiset.erase(*boostmultiset.begin());
stdmultiset.erase(*stdmultiset.begin());
if(!CheckEqualContainers(boostmultiset, stdmultiset)){
std::cout << "Error in boostmultiset.erase(*boostmultiset.begin())" << std::endl;
return 1;