S
Soumen
I need to write code to copy unique elements in from a sequence
container (say vector) to a set (or another sequence container will
do). Is following code efficient?
template <class T>
void copyUniqueObject(const vector<T> &seqContainer,
set<T> &uniqueSet)
{
std::copy(seqContainer.begin(), seqContainer.end(),
std::inserter(uniqueSet, uniqueSet.end()));
}
Or is there a better (more efficient) way (say, some way using
lower_bound or so) to write similar functionality?
Does using unique_copy over copy gives any advantage in this case?
Thanks in advance,
Regards,
~ Soumen
container (say vector) to a set (or another sequence container will
do). Is following code efficient?
template <class T>
void copyUniqueObject(const vector<T> &seqContainer,
set<T> &uniqueSet)
{
std::copy(seqContainer.begin(), seqContainer.end(),
std::inserter(uniqueSet, uniqueSet.end()));
}
Or is there a better (more efficient) way (say, some way using
lower_bound or so) to write similar functionality?
Does using unique_copy over copy gives any advantage in this case?
Thanks in advance,
Regards,
~ Soumen