///////////////////////////////////////////////////////////////////////////////
// RegularityCheckCache.hh
// 
// This file contains a cache for the regularity checks. When we walk down a
// flip and then check all the flips of the target triangulations for
// regularity, many of them will already have been previously checked, so a
// cache should be useful.
///////////////////////////////////////////////////////////////////////////////
#ifndef REGULARITYCHECKCACHE_HH
#define REGULARITYCHECKCACHE_HH
#include "mptopcom_typedefs.hh"
#include "TriangNode.hh"
#include "LRUCache.hh"
#include "GKZ.hh"
class RegularityCheckCache {
   private:
      mutable LRUCache<TriangNode, bool> cache;
      const gkz_type& gkz;

   public: 
      RegularityCheckCache(int size, const gkz_type& gkz_in):
          gkz(gkz_in), cache(size){};

      bool isRegular(const TriangNode& t) const{
         bool result;
         if(cache.exist(t)){
            result = cache.get(t);
         } else {
            result = gkz.isRegular(t);
            cache.put(t, result);
         }
         return result;
      }
};

#endif

