cmAlgorithms: Make cmRemoveDuplicates work with more containers.
Remove the accidental requirement that the input range must be a std::vector.
This commit is contained in:
parent
cae45df772
commit
ba959934a6
@ -258,14 +258,15 @@ typename Range::const_iterator cmRemoveMatching(Range &r, MatchRange const& m)
|
|||||||
template<typename Range>
|
template<typename Range>
|
||||||
typename Range::const_iterator cmRemoveDuplicates(Range& r)
|
typename Range::const_iterator cmRemoveDuplicates(Range& r)
|
||||||
{
|
{
|
||||||
std::vector<typename Range::value_type> unique;
|
typedef std::vector<typename Range::value_type> UniqueVector;
|
||||||
|
UniqueVector unique;
|
||||||
unique.reserve(r.size());
|
unique.reserve(r.size());
|
||||||
std::vector<size_t> indices;
|
std::vector<size_t> indices;
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for(typename Range::const_iterator it = r.begin();
|
for(typename Range::const_iterator it = r.begin();
|
||||||
it != r.end(); ++it, ++count)
|
it != r.end(); ++it, ++count)
|
||||||
{
|
{
|
||||||
const typename Range::iterator low =
|
const typename UniqueVector::iterator low =
|
||||||
std::lower_bound(unique.begin(), unique.end(), *it);
|
std::lower_bound(unique.begin(), unique.end(), *it);
|
||||||
if (low == unique.end() || *low != *it)
|
if (low == unique.end() || *low != *it)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user