112 int mask = (1 <<
n_log) - 1;
121 while ((
i<n_trans) && (
trans[
i].symbol == s))
126 while (
table[p].fst != NULL)
145 return (d == NULL) ? 1 : d->
n_states;
157 return (d == NULL) ? 0 : d->
n_trans;
181 return ((d != NULL) && (d->
n_trans > 0)) ?
188 return ((d != NULL) && (d->
n_trans > 0)) ?
195 return (d != NULL) ? d->
key : 0;
209 : i_state(i_state0), symbol(symbol0), o_state(o_state0) {}
220 c_trans = &o->
trans[0];
223 c_trans = e_trans = NULL;
231 int mask = (1<<o->
n_log)-1;
238 c_trans = e_trans = NULL;
244 return c_trans < e_trans;
254 return c_trans->i_state;
259 return c_trans->symbol;
264 return c_trans->o_state;
276 c_trans = &o->
trans[0];
279 c_trans = e_trans = NULL;
285 return c_trans < e_trans;
290 int s = c_trans->symbol;
293 }
while ((c_trans < e_trans) && (s == c_trans->symbol));
298 return c_trans->symbol;
302 template<
class Char,
class Traits>
303 std::basic_ostream<Char,Traits>&
304 operator <<(std::basic_ostream<Char,Traits>& os,
const DFA&
d) {
305 std::basic_ostringstream<Char,Traits> st;
306 st.copyfmt(os); st.
width(0);
307 st <<
"Start state: 0" << std::endl
308 <<
"States: 0..." <<
d.n_states()-1 << std::endl
310 for (
int s = 0; s < static_cast<int>(
d.n_states()); s++) {
316 st << std::endl <<
"\t";
317 st <<
"[" << t.
i_state() <<
"]" 318 <<
"- " << t.
symbol() <<
" >" 325 st << std::endl <<
"Final states: " 327 <<
"\t[" <<
d.final_fst() <<
"] ... [" 328 <<
d.final_lst()-1 <<
"]" 330 return os << st.str();
352 return !(*
this ==
d);
Transitions(const DFA &d)
Initialize to all transitions of DFA d.
int i_state(void) const
Return in-state of current transition.
int n_trans
Number of transitions.
int final_fst
First final state.
int final_fst(void) const
Return the number of the first final state.
void cmb_hash(std::size_t &seed, int h)
Combine hash value h into seed.
void rfree(void *p)
Free memory block starting at p.
Symbols(const DFA &d)
Initialize to symbols of DFA d.
unsigned int width(int i) const
Return width of range at position i.
std::size_t hash(void) const
Return hash key.
void operator++(void)
Move iterator to next transition.
const int max
Largest allowed integer value.
bool operator()(void) const
Test whether iterator still at a transition.
const int min
Smallest allowed integer value.
Specification of transition range.
Transition * trans
The transitions.
const Transition * fst
First transition for the symbol.
Deterministic finite automaton (DFA)
int p
Number of positive literals for node type.
T * alloc(long unsigned int n)
Allocate block of n objects of type T from heap.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
int final_lst
Last final state.
bool operator!=(const DFA &d) const
Test whether DFA is not equal to d.
SharedHandle::Object * object(void) const
Access to the shared object.
virtual ~DFAI(void)
Delete automaton implemenentation.
int n_transitions(void) const
Return the number of transitions.
Specification of a DFA transition.
int symbol_max(void) const
Return largest symbol in DFA.
unsigned int n_symbols
Number of symbols.
bool operator==(const DFA &d) const
Test whether DFA is equal to d.
DFAI(void)
Initialize automaton implementation as empty.
DFA(void)
Initialize for DFA accepting the empty word.
unsigned int max_degree(void) const
Return maximal degree (in-degree and out-degree) of any state.
Heap heap
The single global heap.
HashEntry * table
The transition hash table by symbol.
void fill(void)
Fill hash table.
const Transition * lst
Last transition for the symbol.
Iterator for DFA transitions (sorted by symbols)
void operator++(void)
Move iterator to next symbol.
bool operator()(void) const
Test whether iterator still at a symbol.
int n_states
Number of states.
int n_states(void) const
Return the number of states.
int val(void) const
Return current symbol.
Gecode toplevel namespace
int symbol_min(void) const
Return smallest symbol in DFA.
int n_log
Size of table (as binary logarithm)
int final_lst(void) const
Return the number of the last final state.
#define GECODE_INT_EXPORT
unsigned int n_symbols(void) const
Return the number of symbols.
int symbol(void) const
Return symbol of current transition.
int o_state(void) const
Return out-state of current transition.
unsigned int max_degree
Maximal degree (in-degree and out-degree of any state) and maximal number of transitions per symbol...