From c1b23ffd9296c32548321bfc52efa9d5b55dfc6c Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Mon, 16 Nov 2020 17:02:05 +0100 Subject: [PATCH] reindent --- .../constraint_solver/constraint_solveri.h | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/ortools/constraint_solver/constraint_solveri.h b/ortools/constraint_solver/constraint_solveri.h index 65c8dc12ff..dec3ce0358 100644 --- a/ortools/constraint_solver/constraint_solveri.h +++ b/ortools/constraint_solver/constraint_solveri.h @@ -256,31 +256,23 @@ inline uint64 Hash1(void* const ptr) { template uint64 Hash1(const std::vector& ptrs) { - if (ptrs.empty()) { - return 0; - } else if (ptrs.size() == 1) { - return Hash1(ptrs[0]); - } else { - uint64 hash = Hash1(ptrs[0]); - for (int i = 1; i < ptrs.size(); ++i) { - hash = hash * i + Hash1(ptrs[i]); - } - return hash; + if (ptrs.empty()) return 0; + if (ptrs.size() == 1) return Hash1(ptrs[0]); + uint64 hash = Hash1(ptrs[0]); + for (int i = 1; i < ptrs.size(); ++i) { + hash = hash * i + Hash1(ptrs[i]); } + return hash; } inline uint64 Hash1(const std::vector& ptrs) { - if (ptrs.empty()) { - return 0; - } else if (ptrs.size() == 1) { - return Hash1(ptrs[0]); - } else { - uint64 hash = Hash1(ptrs[0]); - for (int i = 1; i < ptrs.size(); ++i) { - hash = hash * i + Hash1(ptrs[i]); - } - return hash; + if (ptrs.empty()) return 0; + if (ptrs.size() == 1) return Hash1(ptrs[0]); + uint64 hash = Hash1(ptrs[0]); + for (int i = 1; i < ptrs.size(); ++i) { + hash = hash * i + Hash1(ptrs[i]); } + return hash; } /// Reversible Immutable MultiMap class. @@ -3000,20 +2992,12 @@ inline void FillValues(const std::vector& vars, inline int64 PosIntDivUp(int64 e, int64 v) { DCHECK_GT(v, 0); - if (e >= 0) { - return e % v == 0 ? e / v : e / v + 1; - } else { - return e / v; - } + return (e < 0 || e % v == 0) ? e / v : e / v + 1; } inline int64 PosIntDivDown(int64 e, int64 v) { DCHECK_GT(v, 0); - if (e >= 0) { - return e / v; - } else { - return e % v == 0 ? e / v : e / v - 1; - } + return (e >= 0 || e % v == 0) ? e / v : e / v - 1; } std::vector ToInt64Vector(const std::vector& input); @@ -3173,6 +3157,13 @@ class PathState { bool operator<(const IndexArc& other) const { return index < other.index; } }; + // From changed_paths_ and changed_arcs_, fill chains_ and paths_. + // Selection-based algorithm in O(n^2), to use for small change sets. + void MakeChainsFromChangedPathsAndArcsWithSelectionAlgorithm(); + // From changed_paths_ and changed_arcs_, fill chains_ and paths_. + // Generic algorithm in O(std::sort(n)+n), to use for larger change sets. + void MakeChainsFromChangedPathsAndArcsWithGenericAlgorithm(); + // Copies nodes in chains of path at the end of nodes, // and sets those nodes' path member to value path. void CopyNewPathAtEndOfNodes(int path);