What would be the best stl container to use for designing a markov chain

Printable View

- 03-10-2012sigur47Best stl container to use in MY design
What would be the best stl container to use for designing a markov chain

- 03-10-2012brewbuck
std::map<T, std::vector<std:: pair<double, T> > > where T is a type representing a state, ought to do the trick

- 03-10-2012grumpy
Your question, as asked, does not even make sense.

There is no relationship between a STL container (generally contains objects with distinct values that may, or may not, be unique in the container) and a markov chain (a system with the markov property, in which the next state of the system is determined by the current state.

If you want some representation of the sequence of states of a markov chain, then brewbuck's approach might be the trick. - 03-11-2012sigur47
- 03-12-2012VirtualAce
Which container do you think would be best? Research about the various container types should lead you to a best answer and/or a mix of containers that will best suit your needs. Most of the time there is not one magic container that does the trick. You may need to use several different types of containers in order to do what you want.

And if you do use brewbuck's example save yourself some typing and typedef the vector that is acting as the value in the key,value pair as well as the map itself. It not only serves to save typing (and thus possible errors) it also makes the code a bit cleaner and thus more readable.