Thread: Best stl container to use in MY design

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    118

    Best stl container to use in MY design

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

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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);
    //}

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    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.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  4. #4
    Registered User
    Join Date
    Nov 2011
    Posts
    118
    Quote Originally Posted by brewbuck View Post
    std::map<T, std::vector<std:: pair<double, T> > > where T is a type representing a state, ought to do the trick
    What about this

    Code:
        multimap<vector<string>,string  > prefixandsuffix;

  5. #5
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for appropriate container
    By Elysia in forum C++ Programming
    Replies: 20
    Last Post: 07-27-2010, 04:51 PM
  2. container
    By lopezA in forum C++ Programming
    Replies: 5
    Last Post: 12-04-2007, 11:10 AM
  3. Replies: 1
    Last Post: 01-23-2006, 07:12 PM
  4. Replies: 4
    Last Post: 03-21-2004, 03:34 PM
  5. I/O using a STL container
    By LA Mills in forum C++ Programming
    Replies: 5
    Last Post: 04-20-2003, 12:15 PM