PolyBoRi
pbori_routines_cuddext.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00015 //*****************************************************************************
00016 
00017 // include basic definitions
00018 #include "pbori_defs.h"
00019 #include <map>
00020 
00021 #ifndef PBORI_pbori_routines_cuddext_h_
00022 #define PBORI_pbori_routines_cuddext_h_
00023 
00024 BEGIN_NAMESPACE_PBORI
00025 
00027 
00029 template<class MapType, class NaviType>
00030 inline typename MapType::mapped_type
00031 dd_long_count_step(MapType& cache, NaviType navi) {
00032 
00033   if(navi.isConstant())
00034     return navi.terminalValue();
00035 
00036   {
00037     typename MapType::iterator iter = cache.find(navi);
00038     if (iter != cache.end())
00039       return iter->second;
00040   }
00041 
00042   return cache[navi] = 
00043     dd_long_count_step(cache, navi.thenBranch()) +
00044     dd_long_count_step(cache, navi.elseBranch());
00045 }
00046 
00048 template <class IntType, class NaviType>
00049 inline IntType
00050 dd_long_count(NaviType navi) {
00051 
00052   std::map<NaviType, IntType> local_cache;
00053   return dd_long_count_step(local_cache, navi);
00054 }
00055 
00056 END_NAMESPACE_PBORI
00057 
00058 #endif