21#include <spot/misc/common.hh>
38 template<
typename values>
39 void permute_vector(std::vector<values>& data,
40 const std::vector<unsigned>& indices)
42 unsigned n = std::min(data.size(), indices.size());
45 std::vector<bool> done(n,
false);
46 unsigned end_of_data = n - 1;
47 for (
unsigned i = 0; i < n; ++i)
49 if (done[i] || indices[i] == i)
51 unsigned next = indices[i];
58 values tmp = std::move(data[i]);
61 SPOT_ASSERT(next < n);
63 throw std::invalid_argument
64 (
"permute_vector: invalid permutation");
67 values tmp2 = std::move(data[next]);
68 data[next] = std::move(tmp);
69 tmp = std::move(tmp2);
76 data[i] = std::move(tmp);
Definition: automata.hh:26