コード例 #1
0
ファイル: main.cpp プロジェクト: CCJY/coliru
Map3 foo( Map1 const & m1, Map2 const & m2 ) {
    auto m2end = m2.end(); // a constant call is move outside the loop
    Map3 result;
    for( auto & v1 : m1 ) { // each entry in m1 is made of the key as first and the value as second
        for( auto & p1 : v1.second ) { // iterate over the vector of pair
            auto v2it = m2.find( p1 ); // search for the pair
            if ( v2it != m2end ) {
                result[v1.first] += v2it->second; // if the pair was found, add the value for it to the result, using the map1 key as key
            }
        }
    }
    return result;
}
コード例 #2
0
ファイル: DotProduct.hpp プロジェクト: sdl-research/hyp
void intersectValues(Map const& map, Map2 const& map2, DotProductResult& dotResult) {
  if (map.size() < map2.size())
    intersectValues(map.begin(), map.end(), map2, dotResult);
  else
    intersectValues(map, map2.begin(), map2.end(), dotResult);
}