Re: Reasonable expectation: for(it = v.begin(); it != v.end(); it++)
From: Steven T. Hatton (susudata_at_setidava.kushan.aa)
Date: 08/16/04
- Next message: Will Twentyman: "Re: Yet another Attempt at Disproving the Halting Problem"
- Previous message: Alex Vinokur: "Re: Custom allocator sample code for vector"
- In reply to: Richard Herring: "Re: Reasonable expectation: for(it = v.begin(); it != v.end(); it++)"
- Next in thread: Greg Schmidt: "Re: Reasonable expectation: for(it = v.begin(); it != v.end(); it++)"
- Reply: Greg Schmidt: "Re: Reasonable expectation: for(it = v.begin(); it != v.end(); it++)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 16 Aug 2004 07:26:13 -0400
Richard Herring wrote:
>
> If you're really, justifiably (i.e. a profiler told you so!) worried
> about the cost of repeatedly calling v.end(), why not just do this:
>
> for (whatever::iterator it=v.begin(), e=e.end(); it!=e; ++it) {...}
>
> ?
I haven't started messing with a profiler yet - it's not a bad suggestion -,
but in some of the things I do, number crunching is an issue.
Yes, that is an option. For the sake of readability, I would prefer:
whatever::iterator e=v.end();
for (whatever::iterator it=v.begin(); it!=e; ++it) {...}
That will work 99.9% of the time. I am very unlikely to try to grow the
vector in the for() loop, however...
-- STH Hatton's Law: "There is only One inviolable Law" KDevelop: http://www.kdevelop.org SuSE: http://www.suse.com Mozilla: http://www.mozilla.org
- Next message: Will Twentyman: "Re: Yet another Attempt at Disproving the Halting Problem"
- Previous message: Alex Vinokur: "Re: Custom allocator sample code for vector"
- In reply to: Richard Herring: "Re: Reasonable expectation: for(it = v.begin(); it != v.end(); it++)"
- Next in thread: Greg Schmidt: "Re: Reasonable expectation: for(it = v.begin(); it != v.end(); it++)"
- Reply: Greg Schmidt: "Re: Reasonable expectation: for(it = v.begin(); it != v.end(); it++)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|