मुझे यह कोड मिला है और मैं उस भाग को समझ नहीं पा रहा हूं जहां बराबर_रेंज विधि इटरेटर लौटाता है। इस बिल्कुल क्या मतलब है - मैं जानता हूँ कि सीमा जोड़ी के अंदर दो मल्टीमैप वस्तुओं के साथ वस्तु है, लेकिन मैं नहीं मिलता है क्या, क्यों है 'for (it = range.first; it != range.second; ++it)'
है?सी ++: एसटीएल multimap.equal_range()
// multmap.cpp -- use a multimap
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
typedef int KeyType;
typedef std::pair<const KeyType, std::string> Pair;
typedef std::multimap<KeyType, std::string> MapCode;
int main()
{
using namespace std;
MapCode codes;
codes.insert(Pair(415, "San Francisco"));
codes.insert(Pair(510, "Oakland"));
codes.insert(Pair(718, "Brooklyn"));
codes.insert(Pair(718, "Staten Island"));
codes.insert(Pair(415, "San Rafael"));
codes.insert(Pair(510, "Berkeley"));
cout << "Number of cities with area code 415: "
<< codes.count(415) << endl;
cout << "Number of cities with area code 718: "
<< codes.count(718) << endl;
cout << "Number of cities with area code 510: "
<< codes.count(510) << endl;
cout << "Area Code City\n";
MapCode::iterator it;
for (it = codes.begin(); it != codes.end(); ++it)
cout << " " << (*it).first << " "
<< (*it).second << endl;
pair<MapCode::iterator, MapCode::iterator> range
= codes.equal_range(718);
cout << "Cities with area code 718:\n";
for (it = range.first; it != range.second; ++it) //<------------------ here
cout << (*it).second << endl;
return 0;
}
मुझे लगता है कि आपका जवाब, मेरे लिए सबसे समझा जा सकता है क्योंकि यह बार-बार दोहराना से अधिक देखने के लिए जोड़ी वस्तुओं सदस्यों भ्रामक था। लेकिन अगर यह * [कंटेनर.बीजिन(), कंटेनर.एंड()) के समान * है, तो यह ठीक है। धन्यवाद – ashur