Skip to content

Commit

Permalink
more span
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Aug 2, 2024
1 parent 6169627 commit 9e151b4
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions ortools/algorithms/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand Down
5 changes: 3 additions & 2 deletions ortools/algorithms/hungarian_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -51,7 +52,7 @@ void GenericCheck(const int expected_assignment_size,
}
}

void TestMinimization(const std::vector<std::vector<double>>& cost,
void TestMinimization(absl::Span<const std::vector<double>> cost,
const int expected_assignment_size,
const int expected_agents[], const int expected_tasks[]) {
absl::flat_hash_map<int, int> direct_assignment;
Expand All @@ -62,7 +63,7 @@ void TestMinimization(const std::vector<std::vector<double>>& cost,
expected_agents, expected_tasks);
}

void TestMaximization(const std::vector<std::vector<double>>& cost,
void TestMaximization(absl::Span<const std::vector<double>> cost,
const int expected_assignment_size,
const int expected_agents[], const int expected_tasks[]) {
absl::flat_hash_map<int, int> direct_assignment;
Expand Down
2 changes: 1 addition & 1 deletion ortools/graph/cliques_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class CliqueSizeVerifier {
}

std::function<CliqueResponse(const std::vector<int>&)> MakeCliqueCallback() {
return [this](const std::vector<int>& clique) {
return [this](absl::Span<const int> clique) {
return AppendClique(clique) ? CliqueResponse::STOP
: CliqueResponse::CONTINUE;
};
Expand Down
3 changes: 2 additions & 1 deletion ortools/graph/hamiltonian_path_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -92,7 +93,7 @@ TEST(LatticeMemoryManagerTest, Offset) {
}

// Displays the path.
std::string PathToString(const std::vector<int>& path) {
std::string PathToString(absl::Span<const int> path) {
std::string path_string;
const int size = path.size();
for (int i = 0; i < size; i++) {
Expand Down
2 changes: 1 addition & 1 deletion ortools/graph/max_flow_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ void PartialRandomAssignment(typename MaxFlowSolver<Graph>::Solver f,
}

template <typename Graph>
void ChangeCapacities(const std::vector<int64_t>& arc_capacity,
void ChangeCapacities(absl::Span<const int64_t> arc_capacity,
FlowQuantity delta, GenericMaxFlow<Graph>* max_flow) {
const Graph* graph = max_flow->graph();
for (typename Graph::ArcIndex arc = 0; arc < graph->num_arcs(); ++arc) {
Expand Down
2 changes: 1 addition & 1 deletion ortools/util/fp_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ double GetBestScalingOfDoublesToInt64(absl::Span<const double> input,
return scaling_factor;
}

void GetBestScalingOfDoublesToInt64(const std::vector<double>& input,
void GetBestScalingOfDoublesToInt64(absl::Span<const double> input,
int64_t max_absolute_sum,
double* scaling_factor,
double* max_relative_coeff_error) {
Expand Down
2 changes: 1 addition & 1 deletion ortools/util/fp_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>& input,
void GetBestScalingOfDoublesToInt64(absl::Span<const double> input,
int64_t max_absolute_sum,
double* scaling_factor,
double* max_relative_coeff_error);
Expand Down

0 comments on commit 9e151b4

Please sign in to comment.