diff --git a/ortools/algorithms/BUILD.bazel b/ortools/algorithms/BUILD.bazel index e38936416d..1e5a4f12fa 100644 --- a/ortools/algorithms/BUILD.bazel +++ b/ortools/algorithms/BUILD.bazel @@ -166,6 +166,7 @@ cc_test( "//ortools/base:types", "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/random:distributions", + "@com_google_absl//absl/types:span", ], ) diff --git a/ortools/algorithms/hungarian_test.cc b/ortools/algorithms/hungarian_test.cc index 78cb65729a..bb2c196454 100644 --- a/ortools/algorithms/hungarian_test.cc +++ b/ortools/algorithms/hungarian_test.cc @@ -22,6 +22,7 @@ #include "absl/container/flat_hash_map.h" #include "absl/random/distributions.h" +#include "absl/types/span.h" #include "gtest/gtest.h" #include "ortools/base/macros.h" #include "ortools/base/map_util.h" @@ -51,7 +52,7 @@ void GenericCheck(const int expected_assignment_size, } } -void TestMinimization(const std::vector>& cost, +void TestMinimization(absl::Span> cost, const int expected_assignment_size, const int expected_agents[], const int expected_tasks[]) { absl::flat_hash_map direct_assignment; @@ -62,7 +63,7 @@ void TestMinimization(const std::vector>& cost, expected_agents, expected_tasks); } -void TestMaximization(const std::vector>& cost, +void TestMaximization(absl::Span> cost, const int expected_assignment_size, const int expected_agents[], const int expected_tasks[]) { absl::flat_hash_map direct_assignment; diff --git a/ortools/graph/cliques_test.cc b/ortools/graph/cliques_test.cc index 37b4db82a9..d846be1d65 100644 --- a/ortools/graph/cliques_test.cc +++ b/ortools/graph/cliques_test.cc @@ -85,7 +85,7 @@ class CliqueSizeVerifier { } std::function&)> MakeCliqueCallback() { - return [this](const std::vector& clique) { + return [this](absl::Span clique) { return AppendClique(clique) ? CliqueResponse::STOP : CliqueResponse::CONTINUE; }; diff --git a/ortools/graph/hamiltonian_path_test.cc b/ortools/graph/hamiltonian_path_test.cc index e551de9ee1..ffaa436c9f 100644 --- a/ortools/graph/hamiltonian_path_test.cc +++ b/ortools/graph/hamiltonian_path_test.cc @@ -23,6 +23,7 @@ #include "absl/random/distributions.h" #include "absl/strings/str_format.h" +#include "absl/types/span.h" #include "gtest/gtest.h" #include "ortools/base/logging.h" #include "ortools/base/macros.h" @@ -92,7 +93,7 @@ TEST(LatticeMemoryManagerTest, Offset) { } // Displays the path. -std::string PathToString(const std::vector& path) { +std::string PathToString(absl::Span path) { std::string path_string; const int size = path.size(); for (int i = 0; i < size; i++) { diff --git a/ortools/graph/max_flow_test.cc b/ortools/graph/max_flow_test.cc index 0538f28b20..05784665bb 100644 --- a/ortools/graph/max_flow_test.cc +++ b/ortools/graph/max_flow_test.cc @@ -586,7 +586,7 @@ void PartialRandomAssignment(typename MaxFlowSolver::Solver f, } template -void ChangeCapacities(const std::vector& arc_capacity, +void ChangeCapacities(absl::Span arc_capacity, FlowQuantity delta, GenericMaxFlow* max_flow) { const Graph* graph = max_flow->graph(); for (typename Graph::ArcIndex arc = 0; arc < graph->num_arcs(); ++arc) { diff --git a/ortools/util/fp_utils.cc b/ortools/util/fp_utils.cc index 8ca04d1432..98854d8a05 100644 --- a/ortools/util/fp_utils.cc +++ b/ortools/util/fp_utils.cc @@ -194,7 +194,7 @@ double GetBestScalingOfDoublesToInt64(absl::Span input, return scaling_factor; } -void GetBestScalingOfDoublesToInt64(const std::vector& input, +void GetBestScalingOfDoublesToInt64(absl::Span input, int64_t max_absolute_sum, double* scaling_factor, double* max_relative_coeff_error) { diff --git a/ortools/util/fp_utils.h b/ortools/util/fp_utils.h index 884b46a514..34e0a0d8e7 100644 --- a/ortools/util/fp_utils.h +++ b/ortools/util/fp_utils.h @@ -207,7 +207,7 @@ inline bool IsIntegerWithinTolerance(FloatType x, FloatType tolerance) { // // TODO(user): incorporate the gcd computation here? The issue is that I am // not sure if I just do factor /= gcd that round(x * factor) will be the same. -void GetBestScalingOfDoublesToInt64(const std::vector& input, +void GetBestScalingOfDoublesToInt64(absl::Span input, int64_t max_absolute_sum, double* scaling_factor, double* max_relative_coeff_error);