Andre Poenitz <[EMAIL PROTECTED]> writes: | On Sun, Feb 06, 2005 at 12:05:01PM +0100, Lars Gullik Bjønnes wrote: >> | It sort of is, but the criterion how many items are erased is given by >> | the inset argument. >> >> But would be much clearer to use something like >> >> cur.erase(cur.begin() + i, cur.end()); > | *shrug* If this makes the code more clear to tou, use this one. | I was not even aware that someone might object to use resize | to shrink a vector...
Becasue there is a loop with some counting and then it ends up in a resize... utterly confusing. If the loop had had a comment saying that it now calcualtes the new size of the vector, and then progressed to use a resize, outside the loop, then I would not have objected one second. As written now it is just confusing. And it should be done as part of the cursor, not some seemingly unreleated free function. A rollBack function perhaps. >>> using resize for this almost count as obfuscation. >> I think it could even be written like >> >> cur.erase(find_if(cur.begin(), cur.end(), findInset(in)), cur.end()); >> >> i.e. >> >> iterator it = find_if(cur.begin(), cur.end(), findInset(in)); >> if (it != cur.end()) >> cur.erase(it, cur.end); | | Change it if you don't like it. I will, just need to be suer about the deciphering first... -- Lgb