Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7950271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:13:07+00:00 2026-06-04T02:13:07+00:00

I have this structure based multimap and a vector for this structure: typedef std::multimap<char,

  • 0

I have this structure based multimap and a vector for this structure:

typedef std::multimap<char, int> tr;
vector <tr> transitions;

I want to fill the array with values ​​like:

0 0 a
0 1 a
1 1 b
1 2 c
1 3 c

which represent the transitions of an automaton, and i use a vector of std::multimap for the transitions. This assumes that each state corresponds to an integer. How I could do this?. I try:

for (j=0; j<numberTransitions;j++){
    cin>> stateOrigin>>stateDestination>>transitionCharacter;
    transitionsStates.insert(pair<char, int>(transitionCharacter, stateDestination));
    transitions.push_back (transitionsStates);
}

But I’m not sure if it’s correct. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:13:08+00:00Added an answer on June 4, 2026 at 2:13 am

    You never use stateOrigin, so I’m pretty sure it’s wrong (unless I’ve completely misunderstood your intent). I think what you want is more like this:

    typedef std::pair<int, char> trigger;
    std::map<trigger, int> transitions;
    ⋮
    transitions.insert(make_pair(make_pair(orig, chr), dest));
    

    To drive the state machine, you’d use something like this:

    auto newState = transitions.find(make_pair(oldState, inputChar));
    if (newState != transitions.end()) {
        state = newState;
    }
    

    Also note that with C++11 you probably want to use std::unordered_map instead, unless you need efficient access to all the triggers for a given state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have up to 4 files based on this structure (note the prefixes are
I have this structure of classes: public class L3Message { public int Number {
I have this HTML structure and want to convert it to an accordion. <div
I have the following link structure for my portfolio: <?php echo $this->Html->link($post['Portfolio']['title'], array('controller' =>
I have this structure on form, <input type=test value= id=username /> <span class=input-value>John Smith</span>
I have this Structure the elements of which that I need to write in
I have this structure in my html document: <p> <em>You</em> began the evening well,
Suppose i have this structure of elements: <div class=parent> <div class=something1> <div class=something2> <div
I have this HTML structure (excerpt): <td> <select id=test1 class=pub_chooser> <option value=99>All Publications</option> <option
I have this menu structure that is used to navigate through content slider panels.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.