On Wed, Feb 26, 2003 at 03:57:32PM +0000, Angus Leeming wrote: > #include <set> // put this to the beginning of the file > > template<class C> > void eliminate_duplicates(C & c) > { > C unique_c; > std::set<typename C::value_type> s; > > for (typename C::iterator p = c.begin(); p != c.end(); ++p) { > if (s.count(*p) == 0) {
if (s.find(*p) == e.end()) { > unique_c.push_back(*p); > s.insert(*p); > } > } > c = unique_c; Probably faster: swap(c, unique_c) Apart from that I'd use this, especially since the implementation as template suggests thjat it could be re-used for other containers. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)