vector_zeroer(container & vec, const other_container & other_vec) { if(!other_vec.empty()) { vec.resize(1); set_zero(vec.front()); vec.resize(other_vec.size(),vec.front()); } else { vec.resize(0); } }
void insert(It b, It e) { size_t d = std::distance(b, e); if (d == 1) { insert(*b); return; } static container merged; merged.resize(0); merged.reserve(elements.size() + d); if (detail::is_sorted(b, e, comp)) { std::merge(elements.begin(), elements.end(), b, e, std::back_inserter(merged), comp); } else { static container sorted; sorted.assign(b, e); std::sort(sorted.begin(), sorted.end(), comp); std::merge(elements.begin(), elements.end(), sorted.begin(), sorted.end(), std::back_inserter(merged), comp); } merged.swap(elements); iterator it = std::unique(elements.begin(), elements.end()); elements.erase(it, elements.end()); }
void reserve(size_type n) { if (size_ == 0) { elements.resize(n, std::make_pair(res_empty, V())); return; } static container vals; vals.resize(0); vals.reserve(size_); for (size_type i = 0, ie = capacity(); i < ie; ++i) { if (elements[i].first != res_empty && elements[i].first != res_del) { vals.push_back(elements[i]); } } clear(n); size_ = vals.size(); size_t max = capacity() - 1; for (size_type i = 0, ie = vals.size(); i < ie; ++i) { size_t spot = hash_value(vals[i].first) & max; while (elements[spot].first != res_empty && elements[spot].first != vals[i].first) { spot = (spot + 5) & max; } elements[spot] = vals[i]; } }
void make_vector_zeroes( container & vec, const typename container::size_type & d1) { vec.resize(d1); for(auto it=vec.begin(); it!=vec.end(); ++it) { set_zero(*it); } }
void make_vector_default( container & vec, const typename container::size_type & d1, const typename container::size_type & d2, Args... remaining_dims) { vec.clear(); vec.resize(d1); for(auto it=vec.begin(); it!=vec.end(); ++it) { make_vector_default(*it, d2, remaining_dims...); } }
vector_defaulter(container & vec, const other_container & other_vec) { vec.resize(other_vec.size()); auto o_it = other_vec.begin(); for(auto it=vec.begin(); it!=vec.end(); ++it) { vector_defaulter<d-1,decltype(*it),decltype(*o_it)>(*it,*o_it); } }
void make_vector_default( container & vec, const typename container::size_type & d1) { static_assert(std::is_default_constructible<typename container::value_type>::value, "make_default_vector requires that object type is default-constructible."); for(auto it=vec.begin(); it!=vec.end(); ++it) { *it = typename container::value_type(); } vec.resize(d1); }
vector_valuer(container & vec, const value_type & val, const other_container & other_vec) { vec.resize(other_vec.size()); auto o_it = other_vec.begin(); for(auto it=vec.begin(); it!=vec.end(); ++it) { vector_valuer<d-1,decltype(*it),value_type,decltype(*o_it)>(*it,val,*o_it); } }
assignment_coercer(container & obj, const oc & other_obj) { obj.resize(other_obj.size()); auto size = ssize(other_obj); for(decltype(size) i=0; i<size; ++i) { assignment_coercer<d-1,decltype(obj[i])>(obj[i],other_obj[i]); } return; }
assignment_coercer(container & obj, const oc & other_obj) { obj.resize(other_obj.size()); auto o_it = begin(other_obj); for(auto it=begin(obj); it!=end(obj); ++it, ++o_it) { assignment_coercer<d-1,decltype(*it)>(*it,*o_it); } return; }
void make_vector_function( container & vec, const func_type & func, const typename container::size_type & d1, const typename container::size_type & d2, Args... remaining_dims) { vec.clear(); vec.resize(d1); typename container::size_type i(0); auto new_func = [&] (const typename container::size_type & i2, Args... remaining_is) { return func(i,i2,remaining_is...); }; for(auto it=vec.begin(); it!=vec.end(); ++it) { make_vector_function(*it, new_func, d2, remaining_dims...); ++i; } }
vector_defaulter(container & vec, const other_container & other_vec) { vec.clear(); vec.resize(other_vec); }
void make_vector_value( container & vec, const val_type & val, const typename container::size_type & d1) { vec.clear(); vec.resize(d1,val); }