Below is the file 'markov.cc' from this revision. You can also download the file.
#include <iostream> #include <deque> #include "markov.hh" using namespace std; MarkovState::MarkovState () { valid = false; } MarkovState::MarkovState (const deque<token_t> &q) { state = q; } MarkovState::~MarkovState () { } bool MarkovState::operator==(const MarkovState &s) { return s.state == state; } bool MarkovState::operator<(const MarkovState &s) { return s.state < state; } bool MarkovState::operator!=(const MarkovState &s) { return s.state != state; } MarkovModel::MarkovModel (const Stash &s, int length) { const vector<token_t> stash = s.get_stash (); deque<token_t> q; MarkovState last_state; cout << "Hello" << endl; for (vector<token_t>::const_iterator i=stash.begin();i!=stash.end();i++) { q.push_back (*i); cout << "token: " << *i << " : " << q.size() << endl; if (q.size() == length) { MarkovState this_state(q); if (last_state.valid) { markov_pair p(last_state, this_state); edges[p]++; cout << "edges go to " << edges[p] << endl; } last_state = MarkovState (q); q.pop_front(); } } } MarkovModel::~MarkovModel () { }