What would be the best stl container to use for designing a markov chain
What would be the best stl container to use for designing a markov chain
std::map<T, std::vector<std:: pair<double, T> > > where T is a type representing a state, ought to do the trick
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
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.
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.