MultiAgentDecisionProcess  Release 0.2.1
BeliefIteratorSparse.h
Go to the documentation of this file.
1 
28 /* Only include this header file once. */
29 #ifndef _BELIEFITERATORSPARSE_H_
30 #define _BELIEFITERATORSPARSE_H_ 1
31 
32 /* the include directives */
33 #include "Globals.h"
35 #include "BeliefSparse.h"
36 
37 #define BeliefIteratorSparse_UseCIT 0
38 
41 {
42 private:
43 
44 #if BeliefIteratorSparse_UseCIT
45  BeliefSparse::BScit _m_it;
46 #else
48 #endif
50 
51 protected:
52 
53 public:
54 
55  // Constructor, destructor and copy assignment.
57 #if BeliefIteratorSparse_UseCIT
59  {
60  _m_it=_m_belief->_m_b.begin();
61  }
62 #else
64  {
65  if(_m_belief->_m_b.nnz()==0)
66  throw(E("BeliefIteratorSparse ctor: belief is empty"));
67  }
68 #endif
69 
72 
73 #if BeliefIteratorSparse_UseCIT
74  double GetProbability() const { return(*_m_it); }
75  Index GetStateIndex() const { return(_m_it.index()); }
76  bool Next()
77  {
78  _m_it++;
79  if(_m_it==_m_belief->_m_b.end())
80  return(false);
81  else
82  return(true);
83  }
84 #else
85  double GetProbability() const { return(_m_belief->
86  _m_b.value_data()[_m_i]); }
87  Index GetStateIndex() const { return(_m_belief->
88  _m_b.index_data()[_m_i]); }
89  bool Next()
90  {
91  if(_m_i>=(_m_belief->_m_b.nnz()-1))
92  return(false);
93  else
94  {
95  _m_i++;
96  return(true);
97  }
98  }
99 #endif
100 
101  virtual BeliefIteratorSparse* Clone() const
102  { return new BeliefIteratorSparse(*this); }
103 
104 
105 };
106 
107 #endif /* !_BELIEFITERATORSPARSE_H_ */
108 
109 // Local Variables: ***
110 // mode:c++ ***
111 // End: ***