mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
overloaded for_all_elements
This commit is contained in:
@ -1175,20 +1175,10 @@ public:
|
|||||||
|
|
||||||
void clear()noexcept
|
void clear()noexcept
|
||||||
{
|
{
|
||||||
auto pg=arrays.groups;
|
for_all_elements([&,this](group_type* pg,unsigned int n,value_type* p){
|
||||||
auto p=arrays.elements;
|
destroy_element(p);
|
||||||
if(p){
|
pg->reset(n);
|
||||||
for(std::size_t pos=0,last=arrays.groups_size_mask+1;
|
});
|
||||||
pos!=last;++pos,++pg,p+=N){
|
|
||||||
auto mask=pg->match_really_occupied();
|
|
||||||
while(mask){
|
|
||||||
auto n=unchecked_countr_zero(mask);
|
|
||||||
destroy_element(p+n);
|
|
||||||
pg->reset(n);
|
|
||||||
mask&=mask-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
size_=0;
|
size_=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1525,7 +1515,16 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
static void for_all_elements(const arrays_type& arrays_,F f)
|
static auto for_all_elements(const arrays_type& arrays_,F f)
|
||||||
|
->decltype(f(nullptr),void())
|
||||||
|
{
|
||||||
|
for_all_elements(
|
||||||
|
arrays_,[=](group_type*,unsigned int,value_type* p){return f(p);});
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename F>
|
||||||
|
static auto for_all_elements(const arrays_type& arrays_,F f)
|
||||||
|
->decltype(f(nullptr,0,nullptr),void())
|
||||||
{
|
{
|
||||||
auto pg=arrays_.groups;
|
auto pg=arrays_.groups;
|
||||||
auto p=arrays_.elements;
|
auto p=arrays_.elements;
|
||||||
@ -1534,7 +1533,8 @@ private:
|
|||||||
pos!=last;++pos,++pg,p+=N){
|
pos!=last;++pos,++pg,p+=N){
|
||||||
auto mask=pg->match_really_occupied();
|
auto mask=pg->match_really_occupied();
|
||||||
while(mask){
|
while(mask){
|
||||||
f(p+unchecked_countr_zero(mask));
|
auto n=unchecked_countr_zero(mask);
|
||||||
|
f(pg,n,p+n);
|
||||||
mask&=mask-1;
|
mask&=mask-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user