[geos-devel] Iterator adapter - question
mateusz at loskot.net
Fri May 26 04:22:03 EDT 2006
I have 2-3 concepts about the generic iterator adapter
but I'd need some details how would you like to use it.
If you could provide me with some pseudo-code
or some assumptions that would be helpful.
I know the idea but I'd need to know what kind of information
do you want to provide to the adapter and what information
you want to be deduced automatically.
There are a few possibilities, the idea is to have adapter unifying
iterators from STL containers, so you will be able to apply
the same algorithm on different collections.
This is quite simple idea and the only exceptions are trees:
map and multimap containers.
Simples possibility is to specialize the adapter with container:
adapter<std::vector<T> > ( v.begin() );
adapter<std::list<T> > ( v.begin() );
where T is a type of objects stored in container
adapter<std::map<K,V> > ( m.begin() );
where K is a key type and V is a mapped value type
Another option is to specialize only with base iterator:
adapter<std::list<T>::iterator> ( v.begin() );
adapter<std::map<K,V>::iterator> ( v.begin() );
but here the std::map is problematic, because there the adapter is
specialized for map in more sophisticated way - we need a special
dereferencing to make adapter returning only value type, not the pair of
key and value.
Is this similar to your idea?
More information about the geos-devel