|
6 | 6 | #include <cassert> |
7 | 7 |
|
8 | 8 | #include <algorithm> |
9 | | -#include <vector> |
| 9 | +#include <ranges> |
10 | 10 | #include <tuple> |
| 11 | +#include <vector> |
11 | 12 |
|
12 | 13 | #include <sched/Ids.h> |
13 | 14 | #include <sched/support/Range.h> |
@@ -47,16 +48,21 @@ namespace sched::shop { |
47 | 48 | bool has_pending_operations(const MachineOperations& machine_operations) const |
48 | 49 | { |
49 | 50 | assert(machine_operations.size() == machines.size()); |
50 | | - return std::ranges::any_of(machines, [&](std::size_t index) { return index < machine_operations[index].size(); }, &MachineState::index); |
| 51 | + |
| 52 | + for (auto [ machine_index, machine_state ] : std::views::enumerate(machines)) { |
| 53 | + if (machine_state.index < machine_operations[machine_index].size()) { |
| 54 | + return true; |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + return false; |
51 | 59 | } |
52 | 60 |
|
53 | 61 | void update_pending_operations(const MachineOperations& machine_operations) |
54 | 62 | { |
55 | 63 | assert(machine_operations.size() == machines.size()); |
56 | 64 |
|
57 | | - for (std::size_t machine_index : over(machines)) { |
58 | | - MachineState& machine_state = machines[machine_index]; |
59 | | - |
| 65 | + for (auto [ machine_index, machine_state ] : std::views::enumerate(machines)) { |
60 | 66 | for (;;) { |
61 | 67 | if (machine_state.index >= machine_operations[machine_index].size()) { |
62 | 68 | break; |
@@ -89,13 +95,11 @@ namespace sched::shop { |
89 | 95 |
|
90 | 96 | std::vector<std::tuple<OperationId, MachineId>> schedulable_operations; |
91 | 97 |
|
92 | | - for (std::size_t machine_index : over(machines)) { |
93 | | - const MachineState& machine_state = machines[machine_index]; |
94 | | - |
| 98 | + for (auto [ machine_index, machine_state ] : std::views::enumerate(machines)) { |
95 | 99 | // check if the next operation is schedulable |
96 | 100 |
|
97 | 101 | if (machine_state.index >= machine_operations[machine_index].size()) { |
98 | | - break; |
| 102 | + continue; |
99 | 103 | } |
100 | 104 |
|
101 | 105 | const OperationId machine_operation = machine_operations[machine_index][machine_state.index]; |
|
0 commit comments