PolyBoRi
pbori_routines_cuddext.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
15 //*****************************************************************************
16 
17 #ifndef polybori_routines_pbori_routines_cuddext_h_
18 #define polybori_routines_pbori_routines_cuddext_h_
19 
20 // include basic definitions
21 #include <polybori/pbori_defs.h>
22 #include <map>
23 
24 
26 
28 
30 template<class MapType, class NaviType>
31 inline typename MapType::mapped_type
32 dd_long_count_step(MapType& cache, NaviType navi) {
33 
34  if(navi.isConstant())
35  return navi.terminalValue();
36 
37  {
38  typename MapType::iterator iter = cache.find(navi);
39  if (iter != cache.end())
40  return iter->second;
41  }
42 
43  return cache[navi] =
44  dd_long_count_step(cache, navi.thenBranch()) +
45  dd_long_count_step(cache, navi.elseBranch());
46 }
47 
49 template <class IntType, class NaviType>
50 inline IntType
51 dd_long_count(NaviType navi) {
52 
53  std::map<NaviType, IntType> local_cache;
54  return dd_long_count_step(local_cache, navi);
55 }
56 template <class IntType, class NaviType>
57 inline IntType
59  if(navi.isConstant())
60  return navi.terminalValue();
61 
62  return dd_long_count<IntType, NaviType>(navi.thenBranch()) +
63  dd_long_count<IntType, NaviType>(navi.elseBranch());
64 }
65 
67 
68 #endif