87 lines
37 KiB
HTML
87 lines
37 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>OR-Tools</title>
|
|
<meta http-equiv="Content-Type" content="text/html;"/>
|
|
<meta charset="utf-8"/>
|
|
<!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
|
|
<link rel="stylesheet" type="text/css" href="ortools.css" title="default" media="screen,print" />
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="banner-container">
|
|
<div id="banner">
|
|
<span id="sfml">OR-Tools 7.2</span>
|
|
</div>
|
|
</div>
|
|
<link rel="icon" href="https://developers.google.com/optimization/images/orLogo.png">
|
|
<div id="content">
|
|
<!-- Generated by Doxygen 1.8.15 -->
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
</ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(function(){initNavTree('sparse__permutation_8h_source.html','');});
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">sparse_permutation.h</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="sparse__permutation_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">// Copyright 2010-2018 Google LLC</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment">// you may not use this file except in compliance with the License.</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment">// You may obtain a copy of the License at</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment">//</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment">//</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment">// Unless required by applicable law or agreed to in writing, software</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment">// See the License for the specific language governing permissions and</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment">// limitations under the License.</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> </div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="preprocessor">#ifndef OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="preprocessor">#define OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> </div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="preprocessor">#include <string></span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="preprocessor">#include <vector></span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> </div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include "ortools/base/logging.h"</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> </div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="keyword">namespace </span><a class="code" href="namespaceoperations__research.html">operations_research</a> {</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> </div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="comment">// A compact representation for permutations of {0..N-1} that displaces few</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="comment">// elements: it needs only O(K) memory for a permutation that displaces</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="comment">// K elements.</span></div><div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html"> 27</a></span> <span class="keyword">class </span><a class="code" href="classoperations__research_1_1SparsePermutation.html">SparsePermutation</a> {</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  <span class="keyword">public</span>:</div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html#ab4ee5c7df12fcaeb042a8c52654569bd"> 29</a></span>  <span class="keyword">explicit</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#ab4ee5c7df12fcaeb042a8c52654569bd">SparsePermutation</a>(<span class="keywordtype">int</span> size) : size_(size) {} <span class="comment">// Identity.</span></div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> </div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  <span class="comment">// TODO(user,user): complete the reader API.</span></div><div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html#aff385d18c768ffa364c5dccb5fb35c0a"> 32</a></span>  <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#aff385d18c768ffa364c5dccb5fb35c0a">Size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> size_; }</div><div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html#a4941ad4a0095fa3bc4e8aa0e8fb521bf"> 33</a></span>  <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#a4941ad4a0095fa3bc4e8aa0e8fb521bf">NumCycles</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> cycle_ends_.size(); }</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> </div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  <span class="comment">// Returns the "support" of this permutation; that is, the set of elements</span></div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <span class="comment">// displaced by it.</span></div><div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html#a0b05b1e840388f9aba5bbe79a392d7d6"> 37</a></span>  <span class="keyword">const</span> std::vector<int>& <a class="code" href="classoperations__research_1_1SparsePermutation.html#a0b05b1e840388f9aba5bbe79a392d7d6">Support</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> cycles_; }</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span> </div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  <span class="comment">// The permutation has NumCycles() cycles numbered 0 .. NumCycles()-1.</span></div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="comment">// To iterate over cycle #i of the permutation, do this:</span></div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  <span class="comment">// for (const int e : permutation.Cycle(i)) { ...</span></div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="keyword">struct </span>Iterator;</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  Iterator <a class="code" href="classoperations__research_1_1SparsePermutation.html#a59a2f011b1fdc9a63d6557749542c354">Cycle</a>(<span class="keywordtype">int</span> i) <span class="keyword">const</span>;</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> </div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  <span class="comment">// This is useful for iterating over the pair {element, image}</span></div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  <span class="comment">// of a permutation:</span></div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  <span class="comment">//</span></div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <span class="comment">// for (int c = 0; c < perm.NumCycles(); ++c) {</span></div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="comment">// int element = LastElementInCycle(c);</span></div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="comment">// for (int image : perm.Cycle(c)) {</span></div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  <span class="comment">// // The pair is (element, image).</span></div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  <span class="comment">// ...</span></div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="comment">// element = image;</span></div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="comment">// }</span></div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <span class="comment">// }</span></div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  <span class="comment">//</span></div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="comment">// TODO(user): Provide a full iterator for this? Note that we have more</span></div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  <span class="comment">// information with the loop above. Not sure it is needed though.</span></div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#a9fc0ca5752b5ad6cc2a78ff7c512b22a">LastElementInCycle</a>(<span class="keywordtype">int</span> i) <span class="keyword">const</span>;</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span> </div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  <span class="comment">// To add a cycle to the permutation, repeatedly call AddToCurrentCycle()</span></div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  <span class="comment">// with the cycle's orbit, then call CloseCurrentCycle();</span></div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="comment">// This shouldn't be called on trivial cycles (of length 1).</span></div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#ac1e64e1e738964d338be3cac2b2a58fd">AddToCurrentCycle</a>(<span class="keywordtype">int</span> x);</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#ac1e42a48198d2abc8642d81f6b846fee">CloseCurrentCycle</a>();</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span> </div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <span class="comment">// Removes the cycles with given indices from the permutation. This</span></div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  <span class="comment">// works in O(K) for a permutation displacing K elements.</span></div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#abca48ca404a02f35f06f295814407100">RemoveCycles</a>(<span class="keyword">const</span> std::vector<int>& cycle_indices);</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> </div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  <span class="comment">// Output all non-identity cycles of the permutation, sorted</span></div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <span class="comment">// lexicographically (each cycle is described starting by its smallest</span></div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  <span class="comment">// element; and all cycles are sorted lexicographically against each other).</span></div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  <span class="comment">// This isn't efficient; use for debugging only.</span></div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <span class="comment">// Example: "(1 4 3) (5 9) (6 8 7)".</span></div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  std::string <a class="code" href="classoperations__research_1_1SparsePermutation.html#a6886dcada3acf697af20e88ce32a7ae1">DebugString</a>() <span class="keyword">const</span>;</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span> </div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  <span class="keyword">private</span>:</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> size_;</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  std::vector<int> cycles_;</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  std::vector<int> cycle_ends_;</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span> };</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span> </div><div class="line"><a name="l00084"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html#ac1e64e1e738964d338be3cac2b2a58fd"> 84</a></span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#ac1e64e1e738964d338be3cac2b2a58fd">SparsePermutation::AddToCurrentCycle</a>(<span class="keywordtype">int</span> x) {</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  DCHECK_GE(x, 0);</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  DCHECK_LT(x, size_);</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  cycles_.push_back(x);</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span> }</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span> </div><div class="line"><a name="l00090"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html#ac1e42a48198d2abc8642d81f6b846fee"> 90</a></span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#ac1e42a48198d2abc8642d81f6b846fee">SparsePermutation::CloseCurrentCycle</a>() {</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  <span class="keywordflow">if</span> (cycle_ends_.empty()) {</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  DCHECK_GE(cycles_.size(), 2);</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  DCHECK_GE(cycles_.size(), cycle_ends_.back() + 2);</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  }</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  cycle_ends_.push_back(cycles_.size());</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span> }</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span> </div><div class="line"><a name="l00099"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html"> 99</a></span> <span class="keyword">struct </span><a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html">SparsePermutation::Iterator</a> {</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  <span class="comment">// These typedefs allow this iterator to be used within testing::ElementsAre.</span></div><div class="line"><a name="l00101"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a502fa137e188bc3bcf394fd898af8eb5"> 101</a></span>  <span class="keyword">typedef</span> <span class="keywordtype">int</span> <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a502fa137e188bc3bcf394fd898af8eb5">value_type</a>;</div><div class="line"><a name="l00102"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a2a400be7490fa963e8c0cff44a7f199b"> 102</a></span>  <span class="keyword">typedef</span> std::vector<int>::const_iterator <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a2a400be7490fa963e8c0cff44a7f199b">const_iterator</a>;</div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span> </div><div class="line"><a name="l00104"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a5fca038158fb31f2ccd8a6bad141b96a"> 104</a></span>  <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a5fca038158fb31f2ccd8a6bad141b96a">Iterator</a>() {}</div><div class="line"><a name="l00105"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#af753db0fd3ba19caf1d2efdda42bb15e"> 105</a></span>  <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#af753db0fd3ba19caf1d2efdda42bb15e">Iterator</a>(<span class="keyword">const</span> std::vector<int>::const_iterator& b,</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  <span class="keyword">const</span> std::vector<int>::const_iterator& e)</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  : <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#aa12b08b67ec2491e07cba6073d40f847">begin_</a>(b), <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a337e656f1df64dc5910e329459fe6ec3">end_</a>(e) {}</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span> </div><div class="line"><a name="l00109"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a3d0ee250e9f9421b0cfa2ace76b1063f"> 109</a></span>  std::vector<int>::const_iterator <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a3d0ee250e9f9421b0cfa2ace76b1063f">begin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#aa12b08b67ec2491e07cba6073d40f847">begin_</a>; }</div><div class="line"><a name="l00110"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a2bcfdb8bce3544de6ab9b6c6fc572a99"> 110</a></span>  std::vector<int>::const_iterator <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a2bcfdb8bce3544de6ab9b6c6fc572a99">end</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a337e656f1df64dc5910e329459fe6ec3">end_</a>; }</div><div class="line"><a name="l00111"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#aa12b08b67ec2491e07cba6073d40f847"> 111</a></span>  <span class="keyword">const</span> std::vector<int>::const_iterator <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#aa12b08b67ec2491e07cba6073d40f847">begin_</a>;</div><div class="line"><a name="l00112"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a337e656f1df64dc5910e329459fe6ec3"> 112</a></span>  <span class="keyword">const</span> std::vector<int>::const_iterator <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a337e656f1df64dc5910e329459fe6ec3">end_</a>;</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span> </div><div class="line"><a name="l00114"></a><span class="lineno"><a class="line" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a99e9ae420b0274aae3c1fbf997178f41"> 114</a></span>  <span class="keywordtype">int</span> <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a99e9ae420b0274aae3c1fbf997178f41">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a337e656f1df64dc5910e329459fe6ec3">end_</a> - <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#aa12b08b67ec2491e07cba6073d40f847">begin_</a>; }</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span> };</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span> </div><div class="line"><a name="l00117"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html#a59a2f011b1fdc9a63d6557749542c354"> 117</a></span> <span class="keyword">inline</span> <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html">SparsePermutation::Iterator</a> <a class="code" href="classoperations__research_1_1SparsePermutation.html#a59a2f011b1fdc9a63d6557749542c354">SparsePermutation::Cycle</a>(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  DCHECK_GE(i, 0);</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  DCHECK_LT(i, <a class="code" href="classoperations__research_1_1SparsePermutation.html#a4941ad4a0095fa3bc4e8aa0e8fb521bf">NumCycles</a>());</div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  <span class="keywordflow">return</span> <a class="code" href="structoperations__research_1_1SparsePermutation_1_1Iterator.html">Iterator</a>(cycles_.begin() + (i == 0 ? 0 : cycle_ends_[i - 1]),</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  cycles_.begin() + cycle_ends_[i]);</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span> }</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span> </div><div class="line"><a name="l00124"></a><span class="lineno"><a class="line" href="classoperations__research_1_1SparsePermutation.html#a9fc0ca5752b5ad6cc2a78ff7c512b22a"> 124</a></span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="classoperations__research_1_1SparsePermutation.html#a9fc0ca5752b5ad6cc2a78ff7c512b22a">SparsePermutation::LastElementInCycle</a>(<span class="keywordtype">int</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  DCHECK_GE(i, 0);</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  DCHECK_LT(i, cycle_ends_.size());</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  DCHECK_GT(cycle_ends_[i], i == 0 ? 0 : cycle_ends_[i - 1]);</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="keywordflow">return</span> cycles_[cycle_ends_[i] - 1];</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span> }</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span> </div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span> } <span class="comment">// namespace operations_research</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span> </div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span> <span class="preprocessor">#endif // OR_TOOLS_ALGORITHMS_SPARSE_PERMUTATION_H_</span></div><div class="ttc" id="classoperations__research_1_1SparsePermutation_html_ac1e42a48198d2abc8642d81f6b846fee"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#ac1e42a48198d2abc8642d81f6b846fee">operations_research::SparsePermutation::CloseCurrentCycle</a></div><div class="ttdeci">void CloseCurrentCycle()</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00090">sparse_permutation.h:90</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_a59a2f011b1fdc9a63d6557749542c354"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#a59a2f011b1fdc9a63d6557749542c354">operations_research::SparsePermutation::Cycle</a></div><div class="ttdeci">Iterator Cycle(int i) const</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00117">sparse_permutation.h:117</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a5fca038158fb31f2ccd8a6bad141b96a"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a5fca038158fb31f2ccd8a6bad141b96a">operations_research::SparsePermutation::Iterator::Iterator</a></div><div class="ttdeci">Iterator()</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00104">sparse_permutation.h:104</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_abca48ca404a02f35f06f295814407100"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#abca48ca404a02f35f06f295814407100">operations_research::SparsePermutation::RemoveCycles</a></div><div class="ttdeci">void RemoveCycles(const std::vector< int > &cycle_indices)</div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a502fa137e188bc3bcf394fd898af8eb5"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a502fa137e188bc3bcf394fd898af8eb5">operations_research::SparsePermutation::Iterator::value_type</a></div><div class="ttdeci">int value_type</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00101">sparse_permutation.h:101</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a3d0ee250e9f9421b0cfa2ace76b1063f"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a3d0ee250e9f9421b0cfa2ace76b1063f">operations_research::SparsePermutation::Iterator::begin</a></div><div class="ttdeci">std::vector< int >::const_iterator begin() const</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00109">sparse_permutation.h:109</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_a4941ad4a0095fa3bc4e8aa0e8fb521bf"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#a4941ad4a0095fa3bc4e8aa0e8fb521bf">operations_research::SparsePermutation::NumCycles</a></div><div class="ttdeci">int NumCycles() const</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00033">sparse_permutation.h:33</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_aff385d18c768ffa364c5dccb5fb35c0a"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#aff385d18c768ffa364c5dccb5fb35c0a">operations_research::SparsePermutation::Size</a></div><div class="ttdeci">int Size() const</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00032">sparse_permutation.h:32</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_a6886dcada3acf697af20e88ce32a7ae1"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#a6886dcada3acf697af20e88ce32a7ae1">operations_research::SparsePermutation::DebugString</a></div><div class="ttdeci">std::string DebugString() const</div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_af753db0fd3ba19caf1d2efdda42bb15e"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#af753db0fd3ba19caf1d2efdda42bb15e">operations_research::SparsePermutation::Iterator::Iterator</a></div><div class="ttdeci">Iterator(const std::vector< int >::const_iterator &b, const std::vector< int >::const_iterator &e)</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00105">sparse_permutation.h:105</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a99e9ae420b0274aae3c1fbf997178f41"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a99e9ae420b0274aae3c1fbf997178f41">operations_research::SparsePermutation::Iterator::size</a></div><div class="ttdeci">int size() const</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00114">sparse_permutation.h:114</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a2a400be7490fa963e8c0cff44a7f199b"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a2a400be7490fa963e8c0cff44a7f199b">operations_research::SparsePermutation::Iterator::const_iterator</a></div><div class="ttdeci">std::vector< int >::const_iterator const_iterator</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00102">sparse_permutation.h:102</a></div></div>
|
|
<div class="ttc" id="namespaceoperations__research_html"><div class="ttname"><a href="namespaceoperations__research.html">operations_research</a></div><div class="ttdef"><b>Definition:</b> <a href="dense__doubly__linked__list_8h_source.html#l00021">dense_doubly_linked_list.h:21</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a337e656f1df64dc5910e329459fe6ec3"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a337e656f1df64dc5910e329459fe6ec3">operations_research::SparsePermutation::Iterator::end_</a></div><div class="ttdeci">const std::vector< int >::const_iterator end_</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00112">sparse_permutation.h:112</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_a9fc0ca5752b5ad6cc2a78ff7c512b22a"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#a9fc0ca5752b5ad6cc2a78ff7c512b22a">operations_research::SparsePermutation::LastElementInCycle</a></div><div class="ttdeci">int LastElementInCycle(int i) const</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00124">sparse_permutation.h:124</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_a0b05b1e840388f9aba5bbe79a392d7d6"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#a0b05b1e840388f9aba5bbe79a392d7d6">operations_research::SparsePermutation::Support</a></div><div class="ttdeci">const std::vector< int > & Support() const</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00037">sparse_permutation.h:37</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_a2bcfdb8bce3544de6ab9b6c6fc572a99"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#a2bcfdb8bce3544de6ab9b6c6fc572a99">operations_research::SparsePermutation::Iterator::end</a></div><div class="ttdeci">std::vector< int >::const_iterator end() const</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00110">sparse_permutation.h:110</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_ac1e64e1e738964d338be3cac2b2a58fd"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#ac1e64e1e738964d338be3cac2b2a58fd">operations_research::SparsePermutation::AddToCurrentCycle</a></div><div class="ttdeci">void AddToCurrentCycle(int x)</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00084">sparse_permutation.h:84</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html_aa12b08b67ec2491e07cba6073d40f847"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html#aa12b08b67ec2491e07cba6073d40f847">operations_research::SparsePermutation::Iterator::begin_</a></div><div class="ttdeci">const std::vector< int >::const_iterator begin_</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00111">sparse_permutation.h:111</a></div></div>
|
|
<div class="ttc" id="structoperations__research_1_1SparsePermutation_1_1Iterator_html"><div class="ttname"><a href="structoperations__research_1_1SparsePermutation_1_1Iterator.html">operations_research::SparsePermutation::Iterator</a></div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00099">sparse_permutation.h:99</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html">operations_research::SparsePermutation</a></div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00027">sparse_permutation.h:27</a></div></div>
|
|
<div class="ttc" id="classoperations__research_1_1SparsePermutation_html_ab4ee5c7df12fcaeb042a8c52654569bd"><div class="ttname"><a href="classoperations__research_1_1SparsePermutation.html#ab4ee5c7df12fcaeb042a8c52654569bd">operations_research::SparsePermutation::SparsePermutation</a></div><div class="ttdeci">SparsePermutation(int size)</div><div class="ttdef"><b>Definition:</b> <a href="sparse__permutation_8h_source.html#l00029">sparse_permutation.h:29</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
</div>
|
|
<div id="footer-container">
|
|
<div id="footer">
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|