Back to index

texmacs  1.0.7.15
rel_hashmap.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : rel_hashmap.hpp
00004 * DESCRIPTION: see rel_hashmap.cpp
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 REL_HASMAP_H
00013 #define REL_HASMAP_H
00014 #include "hashmap.hpp"
00015 
00016 template<class T, class U> class rel_hashmap;
00017 template<class T, class U> class rel_hashmap_rep;
00018 template<class T, class U> bool is_nil (rel_hashmap<T,U> h);
00019 
00020 template<class T, class U> class rel_hashmap {
00021   CONCRETE_NULL_TEMPLATE_2(rel_hashmap,T,U);
00022   inline rel_hashmap (U init);
00023   inline rel_hashmap (hashmap<T,U> item);
00024   inline rel_hashmap (hashmap<T,U> item, rel_hashmap<T,U> next);
00025   U  operator [] (T x);
00026   U& operator () (T x);
00027 };
00028 
00029 template<class T, class U> class rel_hashmap_rep: concrete_struct {
00030 public:
00031   hashmap<T,U>     item;
00032   rel_hashmap<T,U> next;
00033 
00034   inline rel_hashmap_rep<T,U> (hashmap<T,U> item2, rel_hashmap<T,U> next2):
00035     item(item2), next(next2) {}
00036   bool contains (T x);
00037   void extend ();
00038   void shorten ();
00039   void merge ();
00040   void find_changes (hashmap<T,U>& CH);
00041   void find_differences (hashmap<T,U>& CH);
00042   void change (hashmap<T,U> CH);
00043 
00044   friend class rel_hashmap<T,U>;
00045 };
00046 
00047 CONCRETE_NULL_TEMPLATE_2_CODE(rel_hashmap,class,T,class,U);
00048 #define TMPL template<class T, class U>
00049 TMPL inline rel_hashmap<T,U>::rel_hashmap (U init):
00050   rep (tm_new<rel_hashmap_rep<T,U> > (hashmap<T,U> (init), rel_hashmap<T,U> ())) {}
00051 TMPL inline rel_hashmap<T,U>::rel_hashmap (hashmap<T,U> item):
00052   rep (tm_new<rel_hashmap_rep<T,U> > (item, rel_hashmap<T,U> ())) {}
00053 TMPL inline rel_hashmap<T,U>::rel_hashmap
00054   (hashmap<T,U> item, rel_hashmap<T,U> next):
00055     rep (tm_new<rel_hashmap_rep<T,U> > (item, next)) {}
00056 
00057 TMPL tm_ostream& operator << (tm_ostream& out, rel_hashmap<T,U> H);
00058 #undef TMPL
00059 
00060 #include "rel_hashmap.cpp"
00061 
00062 #endif // defined REL_HASMAP_H