<ahref="sparse__permutation_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2010-2018 Google LLC</span></div><divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment">// you may not use this file except in compliance with the License.</span></div><divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment">// You may obtain a copy of the License at</span></div><divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00008"></a><spanclass="lineno"> 8</span> <spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div><divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment">// See the License for the specific language governing permissions and</span></div><divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment">// limitations under the License.</span></div><divclass="line"><aname="l00013"></a><spanclass="lineno"> 13</span> </div><divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="preprocessor">#ifndef OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_</span></div><divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="preprocessor">#define OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_</span></div><divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> </div><divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="preprocessor">#include <string></span></div><divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> <spanclass="preprocessor">#include <vector></span></div><divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> </div><divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="preprocessor">#include "ortools/base/logging.h"</span></div><divclass="line"><aname="l00021"></a><spanclass="lineno"> 21</span> </div><divclass="line"><aname="l00022"></a><spanclass="lineno"> 22</span> <spanclass="keyword">namespace </span><aclass="code"href="namespaceoperations__research.html">operations_research</a> {</div><divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> </div><divclass="line"><aname="l00024"></a><spanclass="lineno"> 24</span> <spanclass="comment">// A compact representation for permutations of {0..N-1} that displaces few</span></div><divclass="line"><aname="l00025"></a><spanclass="lineno"> 25</span> <spanclass="comment">// elements: it needs only O(K) memory for a permutation that displaces</span></div><divclass="line"><aname="l00026"></a><spanclass="lineno"> 26</span> <spanclass="comment">// K elements.</span></div><divclass="line"><aname="l00027"></a><spanclass="lineno"><aclass="line"href="classoperations__research_1_1SparsePermutation.html"> 2
<divclass="ttc"id="classoperations__research_1_1SparsePermutation_html_abca48ca404a02f35f06f295814407100"><divclass="ttname"><ahref="classoperations__research_1_1SparsePermutation.html#abca48ca404a02f35f06f295814407100">operations_research::SparsePermutation::RemoveCycles</a></div><divclass="ttdeci">void RemoveCycles(const std::vector< int >&cycle_indices)</div><divclass="ttdoc">Removes the cycles with given indices from the permutation.</div></div>
<divclass="ttc"id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a502fa137e188bc3bcf394fd898af8eb5"><divclass="ttname"><ahref="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a502fa137e188bc3bcf394fd898af8eb5">operations_research::SparsePermutation::Iterator::value_type</a></div><divclass="ttdeci">int value_type</div><divclass="ttdoc">These typedefs allow this iterator to be used within testing::ElementsAre.</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00101">sparse_permutation.h:101</a></div></div>
<divclass="ttc"id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a3d0ee250e9f9421b0cfa2ace76b1063f"><divclass="ttname"><ahref="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a3d0ee250e9f9421b0cfa2ace76b1063f">operations_research::SparsePermutation::Iterator::begin</a></div><divclass="ttdeci">std::vector< int >::const_iterator begin() const</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00109">sparse_permutation.h:109</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SparsePermutation_html_a6886dcada3acf697af20e88ce32a7ae1"><divclass="ttname"><ahref="classoperations__research_1_1SparsePermutation.html#a6886dcada3acf697af20e88ce32a7ae1">operations_research::SparsePermutation::DebugString</a></div><divclass="ttdeci">std::string DebugString() const</div><divclass="ttdoc">Output all non-identity cycles of the permutation, sorted lexicographically (each cycle is described ...</div></div>
<divclass="ttc"id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_af753db0fd3ba19caf1d2efdda42bb15e"><divclass="ttname"><ahref="structoperations__research_1_1SparsePermutation_1_1Iterator.html#af753db0fd3ba19caf1d2efdda42bb15e">operations_research::SparsePermutation::Iterator::Iterator</a></div><divclass="ttdeci">Iterator(const std::vector< int >::const_iterator &b, const std::vector< int >::const_iterator &e)</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00105">sparse_permutation.h:105</a></div></div>
<divclass="ttc"id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a2a400be7490fa963e8c0cff44a7f199b"><divclass="ttname"><ahref="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a2a400be7490fa963e8c0cff44a7f199b">operations_research::SparsePermutation::Iterator::const_iterator</a></div><divclass="ttdeci">std::vector< int >::const_iterator const_iterator</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00102">sparse_permutation.h:102</a></div></div>
<divclass="ttc"id="namespaceoperations__research_html"><divclass="ttname"><ahref="namespaceoperations__research.html">operations_research</a></div><divclass="ttdoc">Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in c...</div><divclass="ttdef"><b>Definition:</b><ahref="dense__doubly__linked__list_8h_source.html#l00021">dense_doubly_linked_list.h:21</a></div></div>
<divclass="ttc"id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a337e656f1df64dc5910e329459fe6ec3"><divclass="ttname"><ahref="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a337e656f1df64dc5910e329459fe6ec3">operations_research::SparsePermutation::Iterator::end_</a></div><divclass="ttdeci">const std::vector< int >::const_iterator end_</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00112">sparse_permutation.h:112</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SparsePermutation_html_a9fc0ca5752b5ad6cc2a78ff7c512b22a"><divclass="ttname"><ahref="classoperations__research_1_1SparsePermutation.html#a9fc0ca5752b5ad6cc2a78ff7c512b22a">operations_research::SparsePermutation::LastElementInCycle</a></div><divclass="ttdeci">int LastElementInCycle(int i) const</div><divclass="ttdoc">This is useful for iterating over the pair {element, image} of a permutation:</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00124">sparse_permutation.h:124</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SparsePermutation_html_a0b05b1e840388f9aba5bbe79a392d7d6"><divclass="ttname"><ahref="classoperations__research_1_1SparsePermutation.html#a0b05b1e840388f9aba5bbe79a392d7d6">operations_research::SparsePermutation::Support</a></div><divclass="ttdeci">const std::vector< int >& Support() const</div><divclass="ttdoc">Returns the "support" of this permutation; that is, the set of elements displaced by it.</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00037">sparse_permutation.h:37</a></div></div>
<divclass="ttc"id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a2bcfdb8bce3544de6ab9b6c6fc572a99"><divclass="ttname"><ahref="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a2bcfdb8bce3544de6ab9b6c6fc572a99">operations_research::SparsePermutation::Iterator::end</a></div><divclass="ttdeci">std::vector< int >::const_iterator end() const</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00110">sparse_permutation.h:110</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SparsePermutation_html_ac1e64e1e738964d338be3cac2b2a58fd"><divclass="ttname"><ahref="classoperations__research_1_1SparsePermutation.html#ac1e64e1e738964d338be3cac2b2a58fd">operations_research::SparsePermutation::AddToCurrentCycle</a></div><divclass="ttdeci">void AddToCurrentCycle(int x)</div><divclass="ttdoc">To add a cycle to the permutation, repeatedly call AddToCurrentCycle() with the cycle's orbit,...</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00084">sparse_permutation.h:84</a></div></div>
<divclass="ttc"id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_aa12b08b67ec2491e07cba6073d40f847"><divclass="ttname"><ahref="structoperations__research_1_1SparsePermutation_1_1Iterator.html#aa12b08b67ec2491e07cba6073d40f847">operations_research::SparsePermutation::Iterator::begin_</a></div><divclass="ttdeci">const std::vector< int >::const_iterator begin_</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00111">sparse_permutation.h:111</a></div></div>
<divclass="ttc"id="classoperations__research_1_1SparsePermutation_html"><divclass="ttname"><ahref="classoperations__research_1_1SparsePermutation.html">operations_research::SparsePermutation</a></div><divclass="ttdoc">A compact representation for permutations of {0..N-1} that displaces few elements: it needs only O(K)...</div><divclass="ttdef"><b>Definition:</b><ahref="sparse__permutation_8h_source.html#l00027">sparse_permutation.h:27</a></div></div>