Returns the non-empty subsets of {0, 1, ..., n}. For example, PowerSetOfIota(3) = {{0}, {1}, {2}, {0,1}, {0,2}, {1,2}, {0,1,2}}.
| 136 | // Returns the non-empty subsets of {0, 1, ..., n}. For example, |
| 137 | // PowerSetOfIota(3) = {{0}, {1}, {2}, {0,1}, {0,2}, {1,2}, {0,1,2}}. |
| 138 | std::vector<std::vector<int64>> PowerSetOfIota(int64 n) { |
| 139 | std::vector<std::vector<int64>> power_set; |
| 140 | for (int64 i = 1; i < (1 << n); ++i) { |
| 141 | power_set.emplace_back(); |
| 142 | for (int64 j = 0; j < n; ++j) { |
| 143 | if (i & (1 << j)) { |
| 144 | power_set.back().push_back(j); |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | return power_set; |
| 149 | } |
| 150 | |
| 151 | // Makes a DeviceAssignment assigning replica-id i to devices[i]. |
| 152 | DeviceAssignment MakeDeviceAssn(std::vector<int64> devices) { |
no test coverage detected