00001
00002
00015
00016
00017 #ifndef polybori_routines_pbori_routines_cuddext_h_
00018 #define polybori_routines_pbori_routines_cuddext_h_
00019
00020
00021 #include <polybori/pbori_defs.h>
00022 #include <map>
00023
00024
00025 BEGIN_NAMESPACE_PBORI
00026
00028
00030 template<class MapType, class NaviType>
00031 inline typename MapType::mapped_type
00032 dd_long_count_step(MapType& cache, NaviType navi) {
00033
00034 if(navi.isConstant())
00035 return navi.terminalValue();
00036
00037 {
00038 typename MapType::iterator iter = cache.find(navi);
00039 if (iter != cache.end())
00040 return iter->second;
00041 }
00042
00043 return cache[navi] =
00044 dd_long_count_step(cache, navi.thenBranch()) +
00045 dd_long_count_step(cache, navi.elseBranch());
00046 }
00047
00049 template <class IntType, class NaviType>
00050 inline IntType
00051 dd_long_count(NaviType navi) {
00052
00053 std::map<NaviType, IntType> local_cache;
00054 return dd_long_count_step(local_cache, navi);
00055 }
00056 template <class IntType, class NaviType>
00057 inline IntType
00058 dd_long_count_without_cache(NaviType navi) {
00059 if(navi.isConstant())
00060 return navi.terminalValue();
00061
00062 return dd_long_count<IntType, NaviType>(navi.thenBranch()) +
00063 dd_long_count<IntType, NaviType>(navi.elseBranch());
00064 }
00065
00066 END_NAMESPACE_PBORI
00067
00068 #endif