, 당신은 둘지도에서 고유 항목을 얻을 수 std::set_difference
를 사용할 수 있습니다. 다음 예제를 참조하십시오.
#include <map>
#include <string>
#include <algorithm>
#include <utility>
#include <iterator>
#include <iostream>
int main() {
// Two maps containing some values.
std::map<std::string, int> oldMap { {"test1", 1}, {"test2", 2}, {"test3", 3} };
std::map<std::string, int> newMap { {"test2", 2} };
// Create new map that holds distinct pairs.
std::map<std::string, int> diffMap;
// Add distinct pairs to diffMap.
std::set_difference(begin(oldMap), end(oldMap),
begin(newMap), end(newMap),
std::inserter(diffMap, begin(diffMap)));
// Output result
for (auto& p : diffMap) {
std::cout << p.first << " " << p.second << std::endl;
}
}
출력 :
test1.txt 1
test3.txt 3
이 모두지도에없는 두 개의 항목이 있습니다.
무엇이 문제입니까? – Borgleader
http://www.cplusplus.com/reference/algorithm/set_difference/을보십시오. 또한 이것은 매우 잘못 구성된 질문입니다. – Chad