를 아래의 코드에서 :어떻게 표준에 삽입 ::지도
map<string,vector<int>> create(ifstream& in, const vector<string>& vec)
{
/*holds string and line numbers into which each string appears*/
typedef map<string,vector<int>> myMap;
typedef vector<string>::const_iterator const_iter;
myMap result;
string tmp;
unsigned int lineCounter = 0;
while(std::getline(in,tmp))
{
const_iter beg = vec.begin();
const_iter end = vec.end();
while (beg < end)
{
if (tmp.find(*beg) != string::npos)
{
result[*beg].push_back(lineCounter);//THIS IS THE LINE I'M ASKING FOR
}
++beg;
}
++lineCounter;
}
return result;
}
어떻게 내가 대신 [] 연산자를 사용하여지도의 삽입 방법을 사용하려는 경우가 (라인 코드에 주석 확인)해야합니까?
감사합니다.
내가 닐 내기 그냥 그것의 위해 (불필요한 빈 벡터를 두 번 조회를 피할 수 있지만, 건물)에 대한
Butterworth는 이것을 알고 있습니다 – Default
왜 그 행을 바꾸시겠습니까? –
'vec'요소의 내부 루프는 완전히 정상입니다. 왜 보통의 for 루프를 사용하지 않는가? 나는 루프가 정상 루프와 어떻게 다른지를 알아 내는데 꽤 많은 시간을 보냈다. – MSalters