Пример #1
0
void MarkovTrie<State>::AdvanceSequence(MarkovSequence<State>& ms) {
	TrieNode* t = rootNode;

	for(size_t i = 0; (i < ms.size()) && (t !=  nullptr); i++) {
		t = t->GetChild(ms[i]);
	}

	t = t->GetNext();

	if(t) {
		ms.Append(t->state);
	}
}
Пример #2
0
MarkovSequence<State> MarkovTrie<State>::GenerateSequence(MarkovSequence<State> partialSequence) {
	MarkovSequence<State> ms;

	if(!rootNode) {
		return ms;
	}

	TrieNode* t = rootNode;

	for(size_t i = 0; (i < partialSequence.size()) && (t !=  nullptr); i++) {
		t = t->GetChild(partialSequence[i]);
		ms.Append(partialSequence[i]);
	}
	t = t->GetNext();

	while(t) {
		ms.Append(t->state);
		t = t->GetNext();
	}

	return ms;
}