From 39d4b467ac4333f7abcbbd45fe521864dfaca29c Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Wed, 17 Jul 2024 11:29:47 +0200 Subject: [PATCH] algorithms: std::vector -> absl::Span --- ortools/algorithms/find_graph_symmetries_test.cc | 9 ++++----- ortools/algorithms/hungarian.cc | 2 +- ortools/algorithms/hungarian.h | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ortools/algorithms/find_graph_symmetries_test.cc b/ortools/algorithms/find_graph_symmetries_test.cc index 3789c6927c..8350297924 100644 --- a/ortools/algorithms/find_graph_symmetries_test.cc +++ b/ortools/algorithms/find_graph_symmetries_test.cc @@ -262,8 +262,8 @@ class FindSymmetriesTest : public ::testing::Test { return dense_perm; } - std::vector ComposePermutations(const std::vector& p1, - const std::vector& p2) { + std::vector ComposePermutations(absl::Span p1, + absl::Span p2) { CHECK_EQ(p1.size(), p2.size()); std::vector composed(p1.size(), -1); for (int i = 0; i < p1.size(); ++i) composed[i] = p1[p2[i]]; @@ -274,7 +274,7 @@ class FindSymmetriesTest : public ::testing::Test { // with some basic, non-through EXPECT(..) that check that each generator // does make the group grow. int ComputePermutationGroupSizeAndVerifyBasicIrreductibility( - const std::vector>& generators) { + absl::Span> generators) { if (generators.empty()) return 1; // The identity. const int num_nodes = generators[0]->Size(); // The group only contains the identity at first. @@ -697,8 +697,7 @@ void AddReverseArcsAndFinalize(Graph* graph) { graph->Build(); } -void SetGraphEdges(const std::vector>& edges, - Graph* graph) { +void SetGraphEdges(absl::Span> edges, Graph* graph) { DCHECK_EQ(graph->num_arcs(), 0); for (const auto [from, to] : edges) graph->AddArc(from, to); AddReverseArcsAndFinalize(graph); diff --git a/ortools/algorithms/hungarian.cc b/ortools/algorithms/hungarian.cc index 5dbf9d4186..13ce012024 100644 --- a/ortools/algorithms/hungarian.cc +++ b/ortools/algorithms/hungarian.cc @@ -653,7 +653,7 @@ bool InputContainsNan(absl::Span> input) { } void MinimizeLinearAssignment( - const std::vector>& cost, + absl::Span> cost, absl::flat_hash_map* direct_assignment, absl::flat_hash_map* reverse_assignment) { if (InputContainsNan(cost)) { diff --git a/ortools/algorithms/hungarian.h b/ortools/algorithms/hungarian.h index 19c32fc187..7f24103a3f 100644 --- a/ortools/algorithms/hungarian.h +++ b/ortools/algorithms/hungarian.h @@ -47,7 +47,7 @@ namespace operations_research { // See IMPORTANT NOTE at the top of the file. void MinimizeLinearAssignment( - const std::vector>& cost, + absl::Span> cost, absl::flat_hash_map* direct_assignment, absl::flat_hash_map* reverse_assignment);