Please insert the word you want to query: the
the occurs 12 times.
(line 4) use of a key distinguishes them from the sequential
(line 8) keyvalue pairs. These types use the library pair class,
(line 9) defined in the utility header, to represent these pairs.
(line 11) that is a pair. The first member of the pair is a const
(line 12) key, and the second member is a value associated with
(line 16) with the same key.
(line 19) the sequential containers. However, the associative
(line 20) containers define some new operations and redefine the
(line 22) common with the sequential containers. The differences
(line 23) in the operations reflect the use of keys in associative
(line 28) elements in order by key. The begin operation yields the
(line 29) element with the lowest key. Incrementing that iterator
Please insert the word you want to query: order
order occurs 1 times.
(line 28) elements in order by key. The begin operation yields the
Please insert the word you want to query: ^Z
Press any key to continue
cout<<"Please insert the word you want to query: ";
while(cin>>word)
{
map_iter=words.find(word);
if(map_iter==words.end())
{
cout<<"Can not find \""<<word<<"\""<<endl;
cout<<"Please insert the word you want to query: ";
continue;
}
cout<<word<<" occurs "<<map_iter->second.size()<<" times.\n";
for(set<line_no>::const_iterator set_iter=map_iter->second.begin();set_iter!=map_iter->second.end();++set_iter)
{
cout<<"\t(line "<<*set_iter<<") "<<lines.at(*set_iter-1)<<endl;
}
cout<<"Please insert the word you want to query: ";
}