I'm using a multimap of the following structure:
typedef std::pair <set <int> , char> trigger;
std::multimap <trigger , set <int> > transitions;
to simulate the transition function of a deterministic finite automata, so that from a set of states it goes by reading a symbol to another set of states. How do i print this multimap? I tried it like this:
for (std::multimap<trigger,set<int> >::iterator it=transitions.begin(); it!=transitions.end(); ++it)
{
for (std::set<int>::iterator its=it.first.first.begin(); its!=it.first.first.end(); ++its)
std::cout << *its<<" ";
std::cout<<(*it).first.second<<endl;
for (std::set<int>::iterator its=it.second.begin(); its!=it.second.end(); ++its)
std::cout << *its<<" ";
}
But it says that the multimap has no member named first or second. Thanks in advance.
The problem with these lines
for (std::set<int>::iterator its=it.first.first.begin(); its!=it.first.first.end(); ++its)
for (std::set<int>::iterator its=it.second.begin(); its!=it.second.end(); ++its)
is that it is an iterator. Use -> access its value.
for (std::set<int>::iterator its=it->first.first.begin(); its!=it->first.first.end(); ++its)
for (std::set<int>::iterator its=it->second.begin(); its!=it->second.end(); ++its)