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 swap( container< A > & l, container< A > & r) { l.swap( r); }