OK, here's my (untested) singly-linked-list iterator:
typedef std::string slist_data;
struct slist_node
{
slist_node* next;
slist_data data;
};
struct slist_policies : default_iterator_policies
{
template <class IteratorAdaptor>
void increment(IteratorAdaptor& x) {
x.base() = x.base()->next;
}
template <class IteratorAdaptor>
typename IteratorAdaptor::reference dereference(IteratorAdaptor& x) {
return x.base()->data;
}
// initialize, equal covered by default policies
};
typedef iterator_adaptor
On Fri, 26 Jul 2002, David Abrahams wrote: dave> dave> Don't you think people will find an iterator which traverses the dave> elements of a real sequence to be more-obvious? That's why I'm dave> suggesting the singly-linked list iterator.
The singly-linked list example was the second thing that popped into my mind... I like that a lot too. Perhaps we should do both :)
Cheers, Jeremy
---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost