A helper to return a transformation sequence identical to |transformations|, except that a chunk of size |chunk_size| starting from |chunk_index| x |chunk_size| is removed (or as many transformations as available if the whole chunk is not).
| 41 | // |chunk_size| is removed (or as many transformations as available if the whole |
| 42 | // chunk is not). |
| 43 | protobufs::TransformationSequence RemoveChunk( |
| 44 | const protobufs::TransformationSequence& transformations, |
| 45 | uint32_t chunk_index, uint32_t chunk_size) { |
| 46 | uint32_t lower = chunk_index * chunk_size; |
| 47 | uint32_t upper = std::min((chunk_index + 1) * chunk_size, |
| 48 | NumRemainingTransformations(transformations)); |
| 49 | assert(lower < upper); |
| 50 | assert(upper <= NumRemainingTransformations(transformations)); |
| 51 | protobufs::TransformationSequence result; |
| 52 | for (uint32_t j = 0; j < NumRemainingTransformations(transformations); j++) { |
| 53 | if (j >= lower && j < upper) { |
| 54 | continue; |
| 55 | } |
| 56 | protobufs::Transformation transformation = |
| 57 | transformations.transformation()[j]; |
| 58 | *result.mutable_transformation()->Add() = transformation; |
| 59 | } |
| 60 | return result; |
| 61 | } |
| 62 | |
| 63 | } // namespace |
| 64 |
no test coverage detected