14#ifndef OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_
15#define OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_
20#include "absl/types/span.h"
33 int Size()
const {
return size_; }
34 int NumCycles()
const {
return cycle_ends_.size(); }
38 const std::vector<int>&
Support()
const {
return cycles_; }
44 Iterator
Cycle(
int i)
const;
81 std::vector<int> cycles_;
82 std::vector<int> cycle_ends_;
92 if (cycle_ends_.empty()) {
93 DCHECK_GE(cycles_.size(), 2);
95 DCHECK_GE(cycles_.size(), cycle_ends_.back() + 2);
97 cycle_ends_.push_back(cycles_.size());
107 const std::vector<int>::const_iterator& e)
111 std::vector<int>::const_iterator
end()
const {
return end_; }
112 const std::vector<int>::const_iterator
begin_;
113 const std::vector<int>::const_iterator
end_;
121 return Iterator(cycles_.begin() + (i == 0 ? 0 : cycle_ends_[i - 1]),
122 cycles_.begin() + cycle_ends_[i]);
127 DCHECK_LT(i, cycle_ends_.size());
128 DCHECK_GT(cycle_ends_[i], i == 0 ? 0 : cycle_ends_[i - 1]);
129 return cycles_[cycle_ends_[i] - 1];
void RemoveCycles(absl::Span< const int > cycle_indices)
const std::vector< int > & Support() const
Iterator Cycle(int i) const
std::string DebugString() const
int LastElementInCycle(int i) const
SparsePermutation(int size)
void AddToCurrentCycle(int x)
In SWIG mode, we don't want anything besides these top-level includes.
std::vector< int >::const_iterator end() const
const std::vector< int >::const_iterator end_
const std::vector< int >::const_iterator begin_
std::vector< int >::const_iterator begin() const
std::vector< int >::const_iterator const_iterator
int value_type
These typedefs allow this iterator to be used within testing::ElementsAre.
Iterator(const std::vector< int >::const_iterator &b, const std::vector< int >::const_iterator &e)