Returns the indices of the first elements of all consecutive subarrays of the given array. For example: ConsecutiveSegments({m, m+1, m+2, n, k, k+1}) = {0, 3, 4}
| 1485 | // given array. For example: |
| 1486 | // ConsecutiveSegments({m, m+1, m+2, n, k, k+1}) = {0, 3, 4} |
| 1487 | static std::vector<size_t> ConsecutiveSegments(absl::Span<const int64> xs) { |
| 1488 | std::vector<size_t> is = {0}; |
| 1489 | for (size_t i = 1; i < xs.size(); ++i) { |
| 1490 | if (1 != xs[i] - xs[i - 1]) { |
| 1491 | is.push_back(i); |
| 1492 | } |
| 1493 | } |
| 1494 | return is; |
| 1495 | } |
| 1496 | |
| 1497 | // Merges the sequences of dimensions of the given shape which start at the |
| 1498 | // given indices `segs`. |
no test coverage detected