Boost logo

Boost :

Subject: Re: [boost] [flat_set] When to sort?
From: Chris Glover (c.d.glover_at_[hidden])
Date: 2017-03-28 20:04:29


>
>
> std::vector<int> buf=s.get_data(); // move, s becomes empty
> for(...)buf.push_back(...); // populate
> s.accept_data(buf); // move and sort
>
>
I like this idea -- but I don't think accept_data can do the sort because
sort might not be enough; the contents might need to be made unique too. We
could add the call to unique inside accept_data, but that pessimises the
case where I know my data is unique. So I think it would need to be more
like;

std::vector<int> buf=move(s).get_data();
for(...) buf.push_back(...); // populate
sort(buf);
unique(buf); // If my contents might not be unique.
s.adopt_ordered_unique_data(move(buf)); // Asserts data is in fact ordered
and unique?

-- chris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk