std::list<Foo>::iterator currIter, nextIter;
currIter = list.begin();
while(currIter != list.end())
{
currIter->doStuff(); // do something with the curr item
nextIter = ++currIter; //advance the iter and set it to next
if(nextIter != list.end()) // still safe to use next item
{
nextIter->doStuff(); // do something with the next item
}
}
Friday, September 12, 2008
Using an STL list with current and next iterators
General algorithm for using a "current" and a "next" iterator on an STL list, which doesn't provide a convenient next() method (random-access containers such as vector do):
Thursday, September 4, 2008
TLDs for TLC
Thanks to "Jon", who pointed out that the Top Level Domain (TLD) example.org is reserved for those times when you need a bogus domain for testing or documentation. Go ahead, click it!
Even better, under RFC 2606 four TLDs are reserved for your testing and documentation pleasure. To quote the RFC:
Even better, under RFC 2606 four TLDs are reserved for your testing and documentation pleasure. To quote the RFC:
TLD | Purpose |
.test | testing of current or new DNS related code |
.example | documentation or examples |
.invalid | online construction of domain names that are sure to be invalid and which it is obvious at a glance are invalid |
.localhost | loop back |
Subscribe to:
Posts (Atom)