00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 #ifndef __CACHE_HPP
00014 #define __CACHE_HPP
00015 #include <basix/table.hpp>
00016 
00018 
00019 namespace mmx {
00020 #define TMPL template<typename C, typename T>
00021 #define Table table<C,T>
00022 #define Cache cache<C,T>
00023 
00024 
00025 
00026 
00027 
00028 TMPL
00029 class cache {
00030 MMX_ALLOCATORS
00031   Table rep;
00032 public:
00033   inline Table operator * () const { return rep; }
00034   inline Table& operator * () { return rep; }
00035   inline cache (): rep (Table ()) {}
00036   inline cache (const Table& c): rep (c) {}
00037 };
00038 
00039 TMPL inline nat hash (const Cache& c) { return hard_hash (*c); }
00040 TMPL inline nat exact_hash (const Cache& c) { return hard_hash (*c); }
00041 TMPL inline nat hard_hash (const Cache& c) { return hard_hash (*c); }
00042 TMPL inline bool operator == (const Cache& c1, const Cache& c2) {
00043   return hard_eq (*c1, *c2); }
00044 TMPL inline bool operator != (const Cache& c1, const Cache& c2) {
00045   return hard_neq (*c1, *c2); }
00046 TMPL inline bool exact_eq (const Cache& c1, const Cache& c2) {
00047   return hard_eq (*c1, *c2); }
00048 TMPL inline bool exact_neq (const Cache& c1, const Cache& c2) {
00049   return hard_neq (*c1, *c2); }
00050 TMPL inline bool hard_eq (const Cache& c1, const Cache& c2) {
00051   return hard_eq (*c1, *c2); }
00052 TMPL inline bool hard_neq (const Cache& c1, const Cache& c2) {
00053   return hard_neq (*c1, *c2); }
00054 
00055 TMPL inline syntactic flatten (const Cache& c) { return flatten (*c); }
00056 
00057 
00058 
00059 
00060 
00061 TMPL inline nat N (const Cache& c) {
00062   return N (*c); }
00063 TMPL inline double complexity (const Cache& c) {
00064   return complexity (*c); }
00065 TMPL inline nat discrete_complexity (const Cache& c) {
00066   return discrete_complexity (*c); }
00067 
00068 TMPL inline void inside_set (const Cache& c, const T& x, const C& v) {
00069   inside_set (*c, x, v); }
00070 TMPL inline void reset (Cache& c, const T& x) {
00071   reset (*c, x); }
00072 TMPL inline bool contains (const Cache& c, const T& x) {
00073   return contains (*c, x); }
00074 TMPL inline C read (const Cache& c, const T& x) {
00075   return read (*c, x); }
00076 TMPL inline iterator<T> entries (const Cache& c) {
00077   return entries (*c); }
00078 TMPL inline Cache append (const Cache& t, const Cache& u) {
00079   return Cache (append (*t, *u)); }
00080 
00081 
00082 
00083 
00084 
00085 template<typename T, typename C> inline Cache
00086 make_cache_1 (const format<T>& fm1, const format<C>& fm2) {
00087   return Cache (table<C,T> (default_cst (fm2), fm1));
00088 }
00089 
00090 template<typename T, typename C> inline Cache
00091 make_cache_2 (const C& init, const format<T>& fm) {
00092   return Cache (table<C,T> (init, fm));
00093 }
00094 
00095 template<typename T, typename C> inline Cache
00096 make_cache_3 (const vector<pair<T,C> >& v) {
00097   return Cache (table<C,T> (default_cst (get_format2 (CF(v))), iterate (v)));
00098 }
00099 
00100 template<typename T, typename C> inline Cache
00101 make_cache_4 (const C& init, const vector<pair<T,C> >& v) {
00102   return Cache (table<C,T> (init, iterate (v)));
00103 }
00104 
00105 #undef TMPL
00106 #undef Table
00107 #undef Cache
00108 } 
00109 #endif // __CACHE_HPP