PolyBoRi
CNodeCounter.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
15 //*****************************************************************************
16 
17 #ifndef polybori_diagram_CNodeCounter_h_
18 #define polybori_diagram_CNodeCounter_h_
19 
20 // include basic definitions
21 #include <polybori/pbori_defs.h>
22 
24 
29 template<class NaviType>
30 class CNodeCounter {
31  typedef CNodeCounter self;
32 
33 public:
34  typedef NaviType navigator;
35  typedef typename NaviType::size_type size_type;
36 
37  CNodeCounter(): m_visited() {}
38  CNodeCounter(const self& rhs): m_visited(rhs.m_visited) {}
39 
41 
43  if (navi.isConstant() || m_visited.count(navi))
44  return 0;
45 
46  m_visited.insert(navi);
47  return (1 + operator()(navi.thenBranch()) + operator()(navi.elseBranch()));
48  }
49 
50 private:
51  std::set<navigator> m_visited;
52 };
53 
55 
56 #endif /* polybori_diagram_CNodeCounter_h_ */