On Friday 09 August 2002 11:30 am, Lars Gullik Bjønnes wrote: > 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.
Ok. So then my first suggestion is an improvemnt on the current code and doesn't change the semantics. Perhaps a comment would be helpful } else { // reset all counters whose index contains match as a // sub-string for (; it != end; ++it) { if (it->first.find(match) != string::npos) it->second.reset(); } } Angus