Angus Leeming <[EMAIL PROTECTED]> writes: | On Friday 09 August 2002 10:37 am, Angus Leeming wrote: > >> Incidentally, why not: >> >> void Counters::reset(string const & match) >> { >> CounterList::iterator it = counterList.begin(); >> CounterList::iterator end = counterList.end(); >> if (match.empty()) { >> for (; it != end; ++it) { >> it->second.reset(); >> } >> } else { >> for (; it != end; ++it) { >> if (it->first.find(match) != string::npos) >> it->second.reset(); >> } >> } >> } > | Actually, shouldn't that be: > | void Counters::reset(string const & match) | { | if (match.empty()) { | CounterList::iterator it = counterList.begin(); | CounterList::iterator end = counterList.end(); | for (; it != end; ++it) { | it->second.reset(); | } | } else { | CounterList::iterator it = counterList.find(match);
Only if: - exact match is wanted. - only one element in counterList can match. | if (it != counterList.end()) | it->second.reset(); | } | } > | ? > | Angus > -- Lgb