14 #ifndef OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_
15 #define OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_
32 int Size()
const {
return size_; }
33 int NumCycles()
const {
return cycle_ends_.size(); }
37 const std::vector<int>&
Support()
const {
return cycles_; }
43 Iterator
Cycle(
int i)
const;
69 void RemoveCycles(
const std::vector<int>& cycle_indices);
80 std::vector<int> cycles_;
81 std::vector<int> cycle_ends_;
91 if (cycle_ends_.empty()) {
94 DCHECK_GE(cycles_.size(), cycle_ends_.back() + 2);
96 cycle_ends_.push_back(cycles_.size());
106 const std::vector<int>::const_iterator& e)
110 std::vector<int>::const_iterator
end()
const {
return end_; }
111 const std::vector<int>::const_iterator
begin_;
112 const std::vector<int>::const_iterator
end_;
120 return Iterator(cycles_.begin() + (i == 0 ? 0 : cycle_ends_[i - 1]),
121 cycles_.begin() + cycle_ends_[i]);
127 DCHECK_GT(cycle_ends_[i], i == 0 ? 0 : cycle_ends_[i - 1]);
128 return cycles_[cycle_ends_[i] - 1];
133 #endif // OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_