Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
interaction_builder.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4
6
7namespace bb::avm2::tracegen {
8
10{
11 // Tag each job with whether its destination-columns fingerprint is being seen for the first
12 // time. The tag is captured up front so the partition predicate doesn't depend on the
13 // unique_ptrs, which the partition implementation may null out via moves.
14 unordered_flat_set<size_t> seen_fingerprints;
16 tagged.reserve(jobs.size());
17
18 for (auto& job : jobs) {
19 auto fp = job->get_destination_columns_fingerprint();
20 auto [_, inserted] = seen_fingerprints.insert(fp);
21 tagged.emplace_back(inserted, std::move(job));
22 }
23
24 // Stable partition: first occurrences come first.
25 std::ranges::stable_partition(tagged, [](const auto& t) { return t.first; });
26
27 for (size_t i = 0; i < tagged.size(); ++i) {
28 jobs[i] = std::move(tagged[i].second);
29 }
30}
31
32} // namespace bb::avm2::tracegen
void order_jobs_by_destination_columns(std::vector< std::unique_ptr< InteractionBuilderInterface > > &jobs)
::ankerl::unordered_dense::set< Key > unordered_flat_set
Definition set.hpp:11
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13