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()); }
static void hex_to_binary (fwditer first, fwditer last, container& out) { struct table { int val[256]; table () { std::fill (val, val+256, 0); for (int i = 0; i < 10; ++i) val ['0'+i] = i; for (int i = 0; i < 6; ++i) { val ['a'+i] = 10 + i; val ['a'+i] = 10 + i; } } int operator[] (int i) { return val[i]; } }; static table lut; out.reserve (std::distance (first, last) / 2); while (first != last) { auto const hi (lut[(*first++)]); auto const lo (lut[(*first++)]); out.push_back ((hi*16)+lo); } }
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_function( container & vec, const func_type & func, const typename container::size_type & d1) { vec.clear(); vec.reserve(d1); typename container::size_type i(0); for(i=0; i<d1; ++i) { vec.push_back(func(i)); } }
vector_functioner(container & vec, const func_type & func, const other_container & other_vec) { const typename container::size_type i; auto new_func = [&] (Args... args) { return func(i,args...); }; vec.clear(); vec.reserve(other_vec.size()); for(i=0; i<other_vec.size(); ++i) { vector_functioner<d-1,decltype(vec[i]),decltype(new_func),decltype(other_vec[i])> (vec[i],new_func,other_vec[i]); } }
BigData(unsigned char exponent){ data.reserve(exponent); for (unsigned char i = 0; i < exponent; i++) data.push_back(0); data.push_back(1); }