Inheritance diagram for pn_state:
Public Member Functions | |
pn_state (const marking &m) | |
Construct a pn_state encapsulating the marking m. | |
int | compare (const state *other) const |
Compare two states (issued of a same Petri net). | |
size_t | hash () const |
Hash a state. | |
state * | clone () const |
Duplicate a state. | |
const compressed_marking & | get_marking () const |
Return the encapsulated compressed marking. | |
Private Attributes | |
compressed_marking | ma |
The encapsulated marking is stored compressed. |
Definition at line 31 of file pnstate.hh.
|
Construct a pn_state encapsulating the marking m.
pn_state::pn_state(const marking& m) : spot::state(), ma(m) { } // |
|
Duplicate a state.
spot::state* pn_state::clone() const { pn_state *m = new pn_state(*this); return m; } // Implements spot::state.
|
|
Compare two states (issued of a same Petri net). This method returns an integer less than, equal to, or greater than zero if this is found, respectively, to be less than, equal to, or greater than other according to bit vector lexicographic order. This method should not be called to compare states from different automata.
int pn_state::compare(const state* other) const { const pn_state* m = dynamic_cast<const pn_state*>(other); assert(m); const std::vector<bool>& b1 = ma.get_vector(); const std::vector<bool>& b2 = m->ma.get_vector(); if (b1.size() < b2.size()) return -1; if (b1.size() > b2.size()) return 1; std::pair<std::vector<bool>::const_iterator, std::vector<bool>::const_iterator> res = std::mismatch(b1.begin(), b1.end(), b2.begin()); if (res.first==b1.end()) return 0; if (*(res.first) && !(*(res.second))) return 1; return -1; } // Implements spot::state.
|
|
Return the encapsulated compressed marking.
const compressed_marking& pn_state::get_marking() const { return ma; } // |
|
Hash a state.
size_t pn_state::hash() const { const int max = sizeof(size_t)*8; size_t res = 0; const std::vector<bool>& b = ma.get_vector(); int min = b.size(); if (min>max) min=max; std::vector<bool>::const_iterator i = b.begin(); for (; min>0; --min, ++i) if (*i) res |= 1<<min; return res; } // Implements spot::state.
|
|
The encapsulated marking is stored compressed. Definition at line 78 of file pnstate.hh. |