185 void Apply(IndexType permutation[],
int permutation_start,
186 int permutation_end) {
187 for (IndexType current = permutation_start; current < permutation_end;
189 IndexType next = permutation[current];
191 const IndexType cycle_start = current;
192 if (cycle_handler_->Unseen(next)) {
193 cycle_handler_->SetSeen(&permutation[current]);
194 DCHECK(!cycle_handler_->Unseen(permutation[current]));
195 cycle_handler_->SetTempFromIndex(current);
196 while (cycle_handler_->Unseen(permutation[next])) {
197 cycle_handler_->SetIndexFromIndex(next, current);
199 next = permutation[next];
200 cycle_handler_->SetSeen(&permutation[current]);
201 DCHECK(!cycle_handler_->Unseen(permutation[current]));
203 cycle_handler_->SetIndexFromTemp(current);
207 DCHECK_EQ(cycle_start, current);