Back to index

texmacs  1.0.7.15
iterator.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : iterator.hpp
00004 * DESCRIPTION: dynamic iterators
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef ITERATOR_H
00013 #define ITERATOR_H
00014 #include "hashset.hpp"
00015 #include "hashmap.hpp"
00016 
00017 extern int iterator_count;
00018 
00019 template<class T> class iterator_rep: public abstract_struct {
00020 public:
00021   inline iterator_rep<T> () { TM_DEBUG(iterator_count++); }
00022   inline virtual ~iterator_rep<T> () { TM_DEBUG(iterator_count--); }
00023   virtual bool busy () = 0;
00024   virtual T next () = 0;
00025   virtual int remains ();
00026 };
00027 
00028 template<class T> struct iterator {
00029   ABSTRACT_TEMPLATE(iterator,T);
00030   operator tree ();
00031 };
00032 ABSTRACT_TEMPLATE_CODE(iterator,class,T);
00033 
00034 template<class T> tm_ostream& operator << (tm_ostream& out, iterator<T> it);
00035 
00036 template<class T, class U> iterator<T> iterate (hashmap<T,U> h);
00037 template<class T> iterator<T> iterate (hashset<T> h);
00038 
00039 #include "iterator.cpp"
00040 
00041 #endif // defined ITERATOR_H