------------------------------------------------------------------------------ * Wrapping around std::shuffle to use vtkMinimalStandardRandomSequence as a custom * generator. */
| 35 | * generator. |
| 36 | */ |
| 37 | void ShuffleArray(std::vector<int>& array, vtkMinimalStandardRandomSequence* rng) |
| 38 | { |
| 39 | for (size_t i = array.size() - 1; i > 0; i--) |
| 40 | { |
| 41 | double value = rng->GetValue() * static_cast<double>(array.size()); |
| 42 | int index = vtkMath::Floor(value); |
| 43 | std::swap(array[i], array[static_cast<int>(index % array.size())]); |
| 44 | rng->Next(); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | //------------------------------------------------------------------------------ |
no test coverage detected