Archive for September, 2008

Using an STL list with current and next iterators

Friday, September 12th, 2008

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):

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-&gt;doStuff(); // do something with the next item
}

}

TLDs for TLC

Thursday, September 4th, 2008

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:

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