00001
00002
00015
00016
00017 #ifndef polybori_diagram_CNodeCounter_h_
00018 #define polybori_diagram_CNodeCounter_h_
00019
00020
00021 #include <polybori/pbori_defs.h>
00022
00023 BEGIN_NAMESPACE_PBORI
00024
00029 template<class NaviType>
00030 class CNodeCounter {
00031 typedef CNodeCounter self;
00032
00033 public:
00034 typedef NaviType navigator;
00035 typedef typename NaviType::size_type size_type;
00036
00037 CNodeCounter(): m_visited() {}
00038 CNodeCounter(const self& rhs): m_visited(rhs.m_visited) {}
00039
00040 ~CNodeCounter() {}
00041
00042 size_type operator()(navigator navi) {
00043 if (navi.isConstant() || m_visited.count(navi))
00044 return 0;
00045
00046 m_visited.insert(navi);
00047 return (1 + operator()(navi.thenBranch()) + operator()(navi.elseBranch()));
00048 }
00049
00050 private:
00051 std::set<navigator> m_visited;
00052 };
00053
00054 END_NAMESPACE_PBORI
00055
00056 #endif