Commit fd72a496 authored by Mikaël Salson's avatar Mikaël Salson

algo/core/automaton: use vector rather than list for state informations

The vector will be slower at insertion but faster at query (cells are
contiguous). Since we spend much more time querying than inserting, this looks
like a better option.
parent f68a0441
#ifndef AUTOMATON_H
#define AUTOMATON_H
#include <list>
#include <vector>
#include <cctype>
#include "kmerstore.h"
#include <cstdlib>
......@@ -53,7 +53,7 @@ public:
/**
* @return the information stored for this state
*/
virtual list<Info> &getInfo(void *state) = 0;
virtual vector<Info> &getInfo(void *state) = 0;
/**
* @param starting_state: the starting state for traversing the automate.
......@@ -104,7 +104,7 @@ class pointer_state {
public:
pointer_state<Info> *transitions[NB_TRANSITIONS]; /* Transitions to the 5 nt */
bool is_final;
list<Info> informations; /* != NULL when is_final */
vector<Info> informations; /* != NULL when is_final */
pointer_state():is_final(false),informations() {
for (size_t i = 0; i < NB_TRANSITIONS; i++)
......@@ -164,7 +164,7 @@ public:
/**
* @return the information stored for this state
*/
list<Info> &getInfo(void *state);
vector<Info> &getInfo(void *state);
/**
* @return the automaton initial state
......
......@@ -4,6 +4,7 @@
#include "automaton.h"
#include <stack>
#include <set>
#include <list>
//////////////////// IMPLEMENTATIONS ////////////////////
template <class Info>
......@@ -160,7 +161,7 @@ void PointerACAutomaton<Info>::build_failure_functions() {
}
template <class Info>
list<Info> &PointerACAutomaton<Info>::getInfo(void *state) {
vector<Info> &PointerACAutomaton<Info>::getInfo(void *state) {
return ((pointer_state<Info> *)state)->informations;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment