#ifndef ITERATORS_H
#define ITERATORS_H

#include <typedefs.h>

/*
Interface for iterators.

  Formed from an algorithmic perpective
  as contrasted with STL's minimal functional perspective.

  In essence there needs to be a start/initialization
  which I call reset();

  The forwarding operation ++.

  The access () or *.

  Is the iterator in a valid state with the !
  operator used to symbolicly do this in
  a visually compact way e.g. !myiter

  I have used this interface in my workspace,
  and found it to be intuitive and useful.

  With the for loop it is also very consise.

  for ( myiter.reset(); !myiter; ++myiter)
  { ...
    dosomething( myiter() ) ...
  }
*/

/*!
\brief Wrap the STL interator concept in the iterator interface with reset(), ++, (), * operations. 

*/
template< typename Cont, typename Tp >
class stl_iterator
{
  Cont & container;
  typename Cont::iterator current;
public:

  /** Constructor. */
  stl_iterator(Cont & container_)
    : container(container_) { current=container.begin(); }

  /** STL begin. */ 
  void reset()
    { current=container.begin(); }

  /** Is the state valid? */
  boolc operator !()
    { return current != container.end(); }
  
  /** Increment. */
  void operator ++()
    { ++current; }
  /** Access reference. */
  Tp & operator * ()
    { return *current; }
  /** Access a constant object. */
  Tp const & operator ()() const
    { return *current; } 

};



#endif


