63 void UpdateBatch( std::span<const PARTITION> aPartitions, EVALUATE&& aEvaluate )
65 std::unordered_multimap<uint64_t, size_t> previous;
68 for(
size_t i = 0; i <
m_entries.size(); ++i )
69 previous.emplace(
m_entries[i]->input.hash, i );
71 auto stale = std::exchange(
m_entries, {} );
72 std::vector<std::unique_ptr<const ENTRY>> current( aPartitions.size() );
73 std::vector<const PARTITION*> missing;
74 std::vector<size_t> ordinals;
76 for(
size_t ordinal = 0; ordinal < aPartitions.size(); ++ordinal )
78 const PARTITION& partition = aPartitions[ordinal];
79 const auto [begin,
end] = previous.equal_range( partition.
hash );
80 const auto found = std::find_if( begin,
end,
81 [&](
const auto& aCandidate )
83 const auto& entry = stale[aCandidate.second];
84 return entry && entry->input == partition;
89 current[ordinal] = std::move( stale[found->second] );
93 missing.push_back( &partition );
94 ordinals.push_back( ordinal );
98 auto values = aEvaluate( missing );
100 if( values.size() != missing.size() )
101 throw std::logic_error(
"Connectivity component batch returned an incorrect result count" );
103 for(
size_t i = 0; i < missing.size(); ++i )
105 current[ordinals[i]] =
106 std::make_unique<const ENTRY>(
ENTRY{ *missing[i], std::move( values[i] ),
m_versions.Next() } );