<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>The answer is 42 dear Watson.</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/updownroundnround/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/updownroundnround/feed.xml</link>
    <description>A collection of posts made in the hope that they will be useful for a tired wayward traveler in search of a solution. Of course, the ultimate answer is 42.</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:28:54 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>The Parent-Container-Child Pattern</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/the-parent-container-child-pattern</link>
      <pubDate>Tue, 09 Feb 2010 09:43:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2010/02/09/the-parent-container-child-pattern/</guid>
      <description><![CDATA[This is an interesting problem that I come across often. There are three types involved in this...]]></description>
      <content:encoded><![CDATA[<p>This is an interesting problem that I come across often. There are three types involved in this pattern:</p>  <p>1.&#160; <font face="Courier"><strong>C</strong></font> – The type of the parent object.</p>  <p>2.&#160; <strong><font face="Courier">O&lt;P&gt;</font></strong> – A collection of instances of <font face="Courier"><strong>P</strong></font>. This is a hybrid collection-dictionary that allows end users to retrieve instances by index or by a key. The implementation extends <font face="Courier">KeyedCollection&lt;K,V&gt;</font>.</p>  <p>3.&#160; <font face="Courier"><strong>P</strong></font> – The type of the instances in <font face="Courier"><strong>O&lt;P&gt;</strong></font>. Instances of <font face="Courier"><strong>P</strong></font> have to maintain a <font face="Courier">Parent</font> relationship with the instance of <font face="Courier"><strong>C</strong></font> that “contains” them. They also have a <font face="Courier">Name</font> property which assigns each instance of <font face="Courier"><strong>P</strong></font> a string name that is unique in its parent container (an instance of <font face="Courier"><strong>O&lt;P&gt;</strong></font>).</p>  <p>While the rest of the behavior is up to the user, we will focus on </p>  <ol>   <li>What should happen when the <font face="Courier">Name</font> or <font face="Courier">Parent</font> of an instance of <font face="Courier"><strong>P</strong></font> changes. </li>    <li>What should happen when an instance of P is added or removed from the <font face="Courier"><strong>O&lt;P&gt;</strong></font> container in an instance of <font face="Courier"><strong>C</strong></font>. </li> </ol>  <p>In this particular specification and implementation, only one instance of an instance of <font face="Courier"><strong>P</strong></font> exists in an instance of <font face="Courier"><strong>O&lt;P&gt;</strong></font> and further, instances are accessed in <font face="Courier">O(1)</font> time by using the <font face="Courier">Name</font> property as a key. </p>  <p>Nor surprisingly, because of the entities involved, I call it the <font face="Courier"><strong>Parent-Container-Child</strong></font> pattern. Of course, I have seen similar patterns, for example in LINQ but I haven’t seen this pattern expressed in a generic form anywhere. Please feel free to post links or resources about similar or the same pattern that is discussed better or implemented better in the comments. While it is possible to implement this with internal functions, state variables etc, here are some restrictions that we will impose that makes the problem less of a hack and more applicable generally:</p>  <ol>   <li>No internal functions. We will only use advertised interfaces and/or public functions. Further, we will not use special functions that could be misused. </li>    <li>No state variables. We do not want to do hacky things such as keeping a state variable to communicate between event handlers etc. </li> </ol>  <p>Interestingly, imposing these restrictions leads to a cleaner design than not imposing them. In fact, my first approach did involve using hacky public functions (that could be misused easily) and state variables to signal that some event handler should not handle a particular event because it was indirectly raised due to an action made by another event handler. This state variable was required to ensure that there was no circular chain of events.</p>  <p>Now, let’s come up with a free format, simple to read technical specification for the above problem.</p>  <p></p>  <hr />  <p></p>  <p><u><font size="2">C</font></u></p>  <blockquote>   <p><font size="2">Contains Properties collection of instances of P.</font></p> </blockquote>  <p><u><font size="2">P</font></u></p>  <p><u><font size="2">Parent Property</font></u></p>  <blockquote>   <p><u><font size="2">When Parent is changed</font></u></p> </blockquote>  <blockquote>   <p><font size="2">a. If old parent and new parent are same instance, no effect.</font></p>    <p><font size="2">b. Signal that parent is going to be changed.</font></p>    <p><font size="2">c. Signal to the new parent that it is becoming the parent of a new child.</font></p>    <p><font size="2">d. Set new parent.</font></p>    <p><font size="2">e. Signal that parent has been changed.</font></p>    <p><font size="2">f. Signal to the new parent that it has become the parent of a new child.</font></p> </blockquote>  <p><u><font size="2">Name Property</font></u></p>  <blockquote>   <p><u><font size="2">When Name is changed</font></u></p> </blockquote>  <blockquote>   <p><font size="2">a. If new value of Name is invalid, throw exception.</font></p>    <p><font size="2">b. If new value of Name and current Name are the same, no effect.</font></p>    <p><font size="2">c. Signal that the name is going to be changed.</font></p>    <p><font size="2">d. Set new name.</font></p>    <p><font size="2">e. Signal that the name has been changed.</font></p> </blockquote>  <p><u><font size="2">O&lt;P&gt;</font></u></p>  <p><u><font size="2">General Operations</font></u></p>  <p><font size="2">a. When an object is added to the collection:</font></p>  <blockquote>   <p><font size="2">1. If its name is incorrect, throw an exception.</font></p>    <p><font size="2">2. If its name already exists, thrown an exception.</font></p>    <p><font size="2">3. Signal that an object is going to be added.</font></p>    <p><font size="2">4. Add the object.</font></p>    <p><font size="2">5. Signal that an object has been added.</font></p>    <p><font size="2">6. Subscribe to name change events on the object.</font></p> </blockquote>  <p><font size="2">b. When an object is removed from the collection:</font></p>  <blockquote>   <p><font size="2">1. If its name is incorrect, throw an exception.</font></p>    <p><font size="2">2. If its name already exists, throw an exception.</font></p>    <p><font size="2">3. Signal that an object is going to be removed.</font></p>    <p><font size="2">4. Unsubscribe from name change events on the object.</font></p>    <p><font size="2">5. Remove the object.</font></p>    <p><font size="2">6. Signal that an object has been removed.</font></p> </blockquote>  <p><font size="2">c. When the collection is cleared:</font></p>  <blockquote>   <p><font size="2">1. Signal that the collection is clearing.</font></p>    <p><font size="2">2. Unsubscribe from name changes for each object.</font></p>    <p><font size="2">3. Signal that the collection has been cleared.</font></p> </blockquote>  <p><u><font size="2">Name Changes</font></u></p>  <blockquote>   <p><u><font size="2" face="Courier New">OnNameChanging</font></u></p>    <p><font size="2">1. Check that the new name does not already exist.</font></p>    <p><u><font size="2" face="Courier New">OnNameChanged</font></u></p>    <p><font size="2">1. Change the name of the object.</font></p> </blockquote>  <p><u><font size="2">Expectations</font></u></p>  <p><font size="2">No circular event handling leading to death by a stack overflow.</font></p>  <p><u><font size="2">Parent is Changed</font></u></p>  <blockquote>   <p><font size="2" face="Courier New">oldParent.Properties.Contains(p) = false</font></p>    <p><font size="2" face="Courier New">newParent.Properties.Contains(p) = true</font></p>    <p><font size="2" face="Courier New">p.Parent = newParent</font></p>    <p><font size="2" face="Courier New">oldParent does not receive events from p.</font></p>    <p><font size="2" face="Courier New">newParent receives events from p.</font></p> </blockquote>  <p><u><font size="2">Name is Changed</font></u></p>  <blockquote>   <p><font size="2" face="Courier New">parent.Properties.Contains(oldName) = false</font></p>    <p><font size="2" face="Courier New">parent.Properties.Contains(newName) = true</font></p>    <p><font size="2" face="Courier New">parent.Properties[newName] = p</font></p> </blockquote>  <p></p>  <hr />  <br />  <p></p>  <p>Based on these specifications, we can figure out the scenarios we will need to test:</p>  <p>In the following, </p>  <ul>   <li>c, c1 and c2 are instances of C. </li>    <li>p is an instance of P. </li> </ul>  <ol>   <li>When an unnamed instance p is added to c.Properties, an exception should be thrown. </li>    <li>When a named but un-parented instance p is added to c.Properties, then      <ul>       <li>The p should acquire c as its Parent. </li>        <li>c.Properties must have an entry for p.Name. </li>        <li>c.Properties[p.Name] should be equal to p. </li>     </ul>   </li>    <li>For an existing named instance p in c.Properties, when p.Name is changed, then      <ul>       <li>p.Parent must still be c. </li>        <li>c.Properties must not have an entry for p’ old name. </li>        <li>c.Properties must have an entry for p.Name. </li>        <li>c.Properties[p.Name] must be p. </li>     </ul>   </li>    <li>When an existing named instance p in c.Properties is removed, then      <ul>       <li>p.Parent must be null. </li>        <li>c.Properties must not have an entry for p.Name </li>     </ul>   </li>    <li>For an existing named instance p in c1.Properties, when p.Parent is changed to c2, then      <ul>       <li>p.Parent must be c2. </li>        <li>c1.Properties must not contain p. </li>        <li>c2.Properties must container p. </li>     </ul>   </li>    <li>For an existing instance p in c1.Properties, when p is added to c2.Properties, then      <ul>       <li>p.Parent must be c2. </li>        <li>c1.Properties should not contain p. </li>        <li>c2.Properties should contain p.&#160; </li>     </ul>   </li> </ol>  <p></p>  <p></p>  <hr />  <p></p>  <p>The complete source code that demonstrates an implementation of the above pattern is provided in this <a href="https://blogs.msdn.com/updownroundnround/AutoParentChild_Final.zip">file</a>. (You will need VSTT 2008 to run the tests). The solution divides the responsibilities of maintaining the relationships correctly amongst <font face="Courier">C</font>, <font face="Courier">P</font> and <font face="Courier">O&lt;P&gt;</font>. Further, for the solution to be correct according to the tests we have outlined, we the order in which actions are performed and the time at which they are performed are important. </p>  <p><u>P</u></p>  <p>Implementation of the type P is rather simple. </p>  <p>When its Name property is changed and the new value is valid and different from its old value, then an event NameChanging is fired before the change is fired and an event NameChanged is fired after the change is persisted.</p>  <p>When its Parent property is changed and the new value is different from its old value, then an event ParentChanging is fired before the change is persisted and an event ParentChanged is fired after the change is persisted. The following code fragment shows how this is implemented:    <br /></p>  <p></p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 79</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 80</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Gets the parent of this instance.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 81</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 82</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;value&gt;</span><span style="color: green">The parent.</span><span style="color: gray">&lt;/value&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 83</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: blue">string</span> Name</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 84</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 85</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">get</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 86</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 87</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: blue">this</span>.name;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 88</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 89</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">set</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 90</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 91</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">value</span> = (<span style="color: blue">value</span> ?? <span style="color: #2b91af">String</span>.Empty).Trim();</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 92</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 93</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: #2b91af">String</span>.IsNullOrEmpty(<span style="color: blue">value</span>))</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 94</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 95</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">ArgumentException</span>(<span style="color: #a31515">&quot;Cannot set the name to an empty or null value.&quot;</span>);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 96</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 97</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 98</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (0 != <span style="color: #2b91af">StringComparer</span>.Ordinal.Compare(<span style="color: blue">this</span>.name, <span style="color: blue">value</span>))</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 99</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 100</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">string</span> oldName = <span style="color: blue">this</span>.name;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 101</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnNameChanging(<span style="color: blue">value</span>, oldName);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 102</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.name = <span style="color: blue">value</span>;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 103</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnNameChanged(<span style="color: blue">value</span>, oldName);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 104</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 105</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 106</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 107</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 108</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 109</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Gets the parent of this instance.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 110</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 111</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;value&gt;</span><span style="color: green">The parent.</span><span style="color: gray">&lt;/value&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 112</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">public</span> <span style="color: #2b91af">Entity</span> Parent</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 113</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 114</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">get</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 115</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 116</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span> <span style="color: blue">this</span>.parent;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 117</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 118</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">set</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 119</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 120</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (!<span style="color: #2b91af">Object</span>.ReferenceEquals(<span style="color: blue">this</span>.parent, <span style="color: blue">value</span>))</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 121</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 122</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">Entity</span> oldParent = <span style="color: blue">this</span>.parent;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 123</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnParentChanging(<span style="color: blue">value</span>, oldParent);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 124</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.parent = <span style="color: blue">value</span>;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 125</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnParentChanged(<span style="color: blue">value</span>, oldParent);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 126</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 127</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 128</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 129</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 130</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 131</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Called after a change to the name of this entity is persisted.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 132</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 133</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;newName&quot;&gt;</span><span style="color: green">The new name.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 134</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;oldName&quot;&gt;</span><span style="color: green">The old name.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 135</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">virtual</span> <span style="color: blue">void</span> OnNameChanged(<span style="color: blue">string</span> newName, <span style="color: blue">string</span> oldName)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 136</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 137</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.NameChanged(<span style="color: blue">this</span>, <span style="color: blue">new</span> <span style="color: #2b91af">NameChangeEventArgs</span>&lt;<span style="color: blue">string</span>&gt;(oldName, newName));</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 138</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 139</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 140</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 141</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Called before a change to the name of this entity is persisted.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 142</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 143</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;newName&quot;&gt;</span><span style="color: green">The new name.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 144</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;oldName&quot;&gt;</span><span style="color: green">The old name.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 145</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">virtual</span> <span style="color: blue">void</span> OnNameChanging(<span style="color: blue">string</span> newName, <span style="color: blue">string</span> oldName)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 146</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 147</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.NameChanging(<span style="color: blue">this</span>, <span style="color: blue">new</span> <span style="color: #2b91af">NameChangeEventArgs</span>&lt;<span style="color: blue">string</span>&gt;(oldName, newName));</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 148</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 149</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 150</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 151</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Called after a change to the parent of this entity is persisted.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 152</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 153</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;newParent&quot;&gt;</span><span style="color: green">The new parent.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 154</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;oldParent&quot;&gt;</span><span style="color: green">The old parent.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 155</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">virtual</span> <span style="color: blue">void</span> OnParentChanged(<span style="color: #2b91af">Entity</span> newParent, <span style="color: #2b91af">Entity</span> oldParent)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 156</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 157</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.ParentChanged(<span style="color: blue">this</span>, <span style="color: blue">new</span> <span style="color: #2b91af">ParentChangeEventArgs</span>&lt;<span style="color: #2b91af">Entity</span>&gt;(oldParent, newParent));</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 158</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 159</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 160</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 161</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Called before a change to the parent of this entity is persisted.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 162</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 163</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;newParent&quot;&gt;</span><span style="color: green">The new parent.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 164</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;oldParent&quot;&gt;</span><span style="color: green">The old parent.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 165</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">virtual</span> <span style="color: blue">void</span> OnParentChanging(<span style="color: #2b91af">Entity</span> newParent, <span style="color: #2b91af">Entity</span> oldParent)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 166</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 167</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.ParentChanging(<span style="color: blue">this</span>, <span style="color: blue">new</span> <span style="color: #2b91af">ParentChangeEventArgs</span>&lt;<span style="color: #2b91af">Entity</span>&gt;(oldParent, newParent));</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 168</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p> </div>  <p></p>  <p>The responsibility of the type P ends here. Thus, its task in the PCC pattern is to ensure that the appropriate checks are carried out and that the appropriate events are fired to notify the parent and the container that some aspect of it is changing.</p>  <p><u><font face="Courier"><strong>O&lt;P&gt;</strong></font></u></p>  <p>Implementing <font face="Courier">O&lt;P&gt;</font> is fairly simple. In the sample implementation, <font face="Courier">O&lt;P&gt;</font> is named <font face="Courier">ObservableKeyedCollection&lt;TKey, TValue&gt;</font> and extends the <font face="Courier">KeyedCollection&lt;K,V&gt;</font> type. The responsibilities of the <font face="Courier">O&lt;P&gt;</font> type in the PCC pattern include:</p>  <ol>   <li>Notify the parent when an item is added or removed or when the collection is cleared. </li>    <li>Listen to Name change events raised by the child instances and update the associated entry for that item. </li>    <li>When an item is added to the collection: fire the ItemAdding event before adding the item and fire the ItemAdded event after adding the item; subscribe to name change events on the item. </li>    <li>When an item is removed from the collection, fire the ItemRemoving event before removing the item and fire the ItemRemoved event after removing the item; unsubscribe from name change events on the item. </li> </ol>  <p>All of these are simple to implement and the following code fragments show how these are implemented in the sample:</p>  <p>&#160;</p>  <p></p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160; 128</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">override</span> <span style="color: blue">void</span> InsertItem(<span style="color: blue">int</span> index, TValue item)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 129</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 130</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnItemAdding(item);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 131</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">base</span>.InsertItem(index, item);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 132</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.Subscribe(item);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 133</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnItemAdded(item);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 134</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p> </div>  <p></p>  <p></p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160; 192</span>&#160;<span style="color: blue">protected</span> <span style="color: blue">override</span> <span style="color: blue">void</span> RemoveItem(<span style="color: blue">int</span> index)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 193</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 194</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TValue item = <span style="color: blue">base</span>[index];</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 195</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnItemRemoving(item);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 196</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">base</span>.RemoveItem(index);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 197</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.Unsubscribe(item);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 198</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnItemRemoved(item);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 199</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p> </div>  <p></p>  <p></p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 89</span>&#160;<span style="color: blue">protected</span> <span style="color: blue">override</span> <span style="color: blue">void</span> ClearItems()</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 90</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 91</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnClearing();</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 92</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">base</span>.ClearItems();</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 93</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.OnCleared();</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 94</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p> </div>  <p></p>  <p></p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 73</span>&#160;<span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 74</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Changes the key of an item to a new value.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 75</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 76</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;oldKey&quot;&gt;</span><span style="color: green">The old key.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 77</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;newKey&quot;&gt;</span><span style="color: green">The new key.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 78</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">protected</span> <span style="color: blue">void</span> ChangeKey(TKey oldKey, TKey newKey)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 79</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 80</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TValue value = <span style="color: blue">this</span>[oldKey];</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 81</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 82</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.Dictionary.Remove(oldKey);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 83</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.Dictionary.Add(newKey, value);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160;&#160; 84</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p> </div>  <p></p>  <p></p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160; 256</span>&#160;<span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 257</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Handles the NameChanged event of the value control.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 258</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 259</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;sender&quot;&gt;</span><span style="color: green">The source of the event.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 260</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;e&quot;&gt;</span><span style="color: green">The </span><span style="color: gray">&lt;see cref=&quot;Microsoft.Test.Environment.Collections.NameChangeEventArgs&amp;lt;TKey&amp;gt;&quot;/&gt;</span><span style="color: green"> instance containing the event data.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 261</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> value_NameChanged(<span style="color: blue">object</span> sender, <span style="color: #2b91af">NameChangeEventArgs</span>&lt;TKey&gt; e)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 262</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 263</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.ChangeKey(e.OldName, e.NewName);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 264</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 265</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 266</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 267</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Handles the NameChanging event of the value control.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 268</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 269</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;sender&quot;&gt;</span><span style="color: green">The source of the event.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 270</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;e&quot;&gt;</span><span style="color: green">The </span><span style="color: gray">&lt;see cref=&quot;Microsoft.Test.Environment.Collections.NameChangeEventArgs&amp;lt;TKey&amp;gt;&quot;/&gt;</span><span style="color: green"> instance containing the event data.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 271</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> value_NameChanging(<span style="color: blue">object</span> sender, <span style="color: #2b91af">NameChangeEventArgs</span>&lt;TKey&gt; e)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 272</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 273</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; TKey newKey = e.NewName;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 274</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 275</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (<span style="color: blue">this</span>.Contains(newKey))</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 276</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 277</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">throw</span> <span style="color: blue">new</span> <span style="color: #2b91af">InvalidOperationException</span>(<span style="color: #2b91af">String</span>.Format(<span style="color: #2b91af">CultureInfo</span>.InvariantCulture, <span style="color: #a31515">&quot;Cannot rename {0} to {1}. An instance with name {1} already exists.&quot;</span>, sender, newKey));</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 278</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 279</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p> </div>  <p></p>  <p><font face="Courier"><strong><u>C</u></strong></font></p>  <p>The parent type C has the responsibility for maintaining the Parent relationship with instances of type P. The following code fragments illustrates how this is implemented in the sample:</p>  <p>&#160;</p>  <p></p>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160; 196</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 197</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Handles the ItemRemoving event of the children control.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 198</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 199</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;sender&quot;&gt;</span><span style="color: green">The source of the event.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 200</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;e&quot;&gt;</span><span style="color: green">The </span><span style="color: gray">&lt;see cref=&quot;Microsoft.Test.Environment.Collections.CollectionChangeEventArgs{T}&quot;/&gt;</span><span style="color: green"> instance containing the event data.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 201</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> children_ItemRemoving(<span style="color: blue">object</span> sender, <span style="color: #2b91af">CollectionChangeEventArgs</span>&lt;<span style="color: #2b91af">Entity</span>&gt; e)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 202</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 203</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.Unsubscribe(e.Value);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 204</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.Value.Parent = <span style="color: blue">null</span>;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 205</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 206</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 207</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 208</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Handles the Clearing event of the children control.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 209</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 210</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;sender&quot;&gt;</span><span style="color: green">The source of the event.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 211</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;e&quot;&gt;</span><span style="color: green">The </span><span style="color: gray">&lt;see cref=&quot;Microsoft.Test.Environment.Collections.CollectionChangeEventArgs{T}&quot;/&gt;</span><span style="color: green"> instance containing the event data.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 212</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> children_Clearing(<span style="color: blue">object</span> sender, <span style="color: #2b91af">CollectionChangeEventArgs</span>&lt;<span style="color: #2b91af">Entity</span>&gt; e)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 213</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 214</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">foreach</span> (<span style="color: #2b91af">Entity</span> child <span style="color: blue">in</span> <span style="color: blue">this</span>.children)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 215</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 216</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.Unsubscribe(child);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 217</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; child.Parent = <span style="color: blue">null</span>;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 218</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 219</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 220</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 221</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 222</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Handles the ItemAdded event of the children control.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 223</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 224</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;sender&quot;&gt;</span><span style="color: green">The source of the event.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 225</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;e&quot;&gt;</span><span style="color: green">The </span><span style="color: gray">&lt;see cref=&quot;Microsoft.Test.Environment.Collections.CollectionChangeEventArgs{T}&quot;/&gt;</span><span style="color: green"> instance containing the event data.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 226</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> children_ItemAdded(<span style="color: blue">object</span> sender, <span style="color: #2b91af">CollectionChangeEventArgs</span>&lt;<span style="color: #2b91af">Entity</span>&gt; e)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 227</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 228</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.Value.Parent = <span style="color: blue">this</span>;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 229</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.Subscribe(e.Value);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 230</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p> </div>  <div style="font-family: courier new; background: white; color: black; font-size: 10pt">   <p style="margin: 0px"><span style="color: #2b91af">&#160; 252</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 253</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> Handles the ParentChanging event of the child control.</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 254</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;/summary&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 255</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;sender&quot;&gt;</span><span style="color: green">The source of the event.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 256</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: gray">///</span><span style="color: green"> </span><span style="color: gray">&lt;param name=&quot;e&quot;&gt;</span><span style="color: green">The </span><span style="color: gray">&lt;see cref=&quot;Microsoft.Test.Environment.Collections.ParentChangeEventArgs{T}&quot;/&gt;</span><span style="color: green"> instance containing the event data.</span><span style="color: gray">&lt;/param&gt;</span></p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 257</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private</span> <span style="color: blue">void</span> child_ParentChanging(<span style="color: blue">object</span> sender, <span style="color: #2b91af">ParentChangeEventArgs</span>&lt;<span style="color: #2b91af">Entity</span>&gt; e)</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 258</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 259</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">Entity</span> child = (<span style="color: #2b91af">Entity</span>)sender;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 260</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">this</span>.children.Remove(child);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 261</span>&#160;</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 262</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span> (!(e.NewParent.Children.Contains(child.Name) &amp;&amp; <span style="color: #2b91af">Object</span>.Equals(e.NewParent.Children[child.Name], child)))</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 263</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 264</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; e.NewParent.Children.Add(child);</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 265</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p style="margin: 0px"><span style="color: #2b91af">&#160; 266</span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p> </div>  <p></p>  <p></p>  <p>&#160;</p>  <p>&#160;</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:bbbd2507-4da9-474a-b340-725a9ae90519" class="wlWriterEditableSmartContent">LiveJournal Tags: <a href="https://www.livejournal.com/interests.bml?int=design" rel="tag">design</a>,<a href="https://www.livejournal.com/interests.bml?int=pattern" rel="tag">pattern</a>,<a href="https://www.livejournal.com/interests.bml?int=relationship" rel="tag">relationship</a>,<a href="https://www.livejournal.com/interests.bml?int=parent" rel="tag">parent</a>,<a href="https://www.livejournal.com/interests.bml?int=container" rel="tag">container</a>,<a href="https://www.livejournal.com/interests.bml?int=child" rel="tag">child</a>,<a href="https://www.livejournal.com/interests.bml?int=maintenance" rel="tag">maintenance</a>,<a href="https://www.livejournal.com/interests.bml?int=automatic" rel="tag">automatic</a></div></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/96/06/05/AutoParentChild_Final.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-96-06-05/AutoParentChild_5F00_Final.zip">AutoParentChild_Final.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Generating All Partitions of A Set – C# Implementation</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/generating-all-partitions-of-a-set-c-implementation</link>
      <pubDate>Fri, 18 Dec 2009 22:17:44 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2009/12/18/generating-all-partitions-of-a-set-c-implementation/</guid>
      <description><![CDATA[The following is the C# implementation of the Fortran algorithm posted in the previous post for...]]></description>
      <content:encoded><![CDATA[<p>The following is the C# implementation of the Fortran algorithm posted in the previous post for generating all possible partitions of a set of items. We consider the items to be unique although they may be the same item (that is Object.Equals returns true) for one or more items in the input set. This is a straightforward implementation that uses a “lazy” enumerator. The implementation is broken into three parts: the first is the <span style="color: #2b91af">IEnumerable</span> implementation. The second is the <span style="color: #2b91af">IEnumerator</span> implementation. The third is the extension method that makes generating all partitions very intuitive and discoverable.</p>  <pre class="code"><span style="color: gray"><font color="#333333">    </font>/// &lt;summary&gt;
    /// </span><span style="color: green">A enumeration of all possible partitions of a set of items.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;typeparam name=&quot;T&quot;&gt;</span><span style="color: green">The type of the items in the set being partitioned.</span><span style="color: gray">&lt;/typeparam&gt;
    </span><span style="color: blue">public sealed class </span><span style="color: #2b91af">AllPartitionsEnumerable</span>&lt;T&gt; : <span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;T&gt;&gt;&gt;
    {
        <span style="color: gray">/// &lt;summary&gt;&lt;/summary&gt;
        </span>[<span style="color: #2b91af">DebuggerBrowsable</span>(<span style="color: #2b91af">DebuggerBrowsableState</span>.Collapsed)]
        <span style="color: blue">private </span><span style="color: #2b91af">IEnumerable</span>&lt;T&gt; items;

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Creates and initializes an instance of the </span><span style="color: gray">&lt;see cref=&quot;AllPartitionsEnumerable{T}&quot;/&gt; </span><span style="color: green">type.
        </span><span style="color: gray">/// &lt;/summary&gt;
        /// &lt;param name=&quot;items&quot;&gt;</span><span style="color: green">The set of items to be partitioned.</span><span style="color: gray">&lt;/param&gt;
        </span><span style="color: blue">public </span>AllPartitionsEnumerable(<span style="color: #2b91af">IEnumerable</span>&lt;T&gt; items)
            : <span style="color: blue">base </span>()
        {
            <span style="color: blue">this</span>.items = items;
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Gets an enumerator to iterate over the partitions in this enumeration.
        </span><span style="color: gray">/// &lt;/summary&gt;
        /// &lt;returns&gt;</span><span style="color: green">An instance of </span><span style="color: gray">&lt;see cref=&quot;IEnumerator{T}&quot;/&gt;</span><span style="color: green">.</span><span style="color: gray">&lt;/returns&gt;
        </span><span style="color: blue">public </span><span style="color: #2b91af">IEnumerator</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;T&gt;&gt;&gt; GetEnumerator()
        {
            <span style="color: blue">return new </span><span style="color: #2b91af">AllPartitionsEnumerator</span>&lt;T&gt;(<span style="color: blue">this</span>.items);
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Gets an enumerator to iterate over the partitions in this enumeration.
        </span><span style="color: gray">/// &lt;/summary&gt;
        /// &lt;returns&gt;</span><span style="color: green">An instance of </span><span style="color: gray">&lt;see cref=&quot;IEnumerator{T}&quot;/&gt;</span><span style="color: green">.</span><span style="color: gray">&lt;/returns&gt;
        </span><span style="color: #2b91af">IEnumerator IEnumerable</span>.GetEnumerator()
        {
            <span style="color: blue">return this</span>.GetEnumerator();
        }
    }</pre>
<a href="https://11011.net/software/vspaste"></a>

<pre class="code"><span style="color: gray">    /// &lt;summary&gt;
    /// </span><span style="color: green">An enumerator to iterate over the items in an instance of </span><span style="color: gray">&lt;see cref=&quot;AllPartitionsEnumerable{T}&quot;/&gt;</span><span style="color: green">.
    </span><span style="color: gray">/// &lt;/summary&gt;
    /// &lt;typeparam name=&quot;T&quot;&gt;</span><span style="color: green">The type of the items in the set being partitioned.</span><span style="color: gray">&lt;/typeparam&gt;
    </span><span style="color: blue">public sealed class </span><span style="color: #2b91af">AllPartitionsEnumerator</span>&lt;T&gt; : <span style="color: #2b91af">IEnumerator</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;T&gt;&gt;&gt;
    {
        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">The original set of items over which partitions are created.</span><span style="color: gray">&lt;/summary&gt;
        </span>[<span style="color: #2b91af">DebuggerBrowsable</span>(<span style="color: #2b91af">DebuggerBrowsableState</span>.Never)]
        <span style="color: blue">private </span>T[] items;

        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">Flag to indicate if this enumerator has been disposed of.</span><span style="color: gray">&lt;/summary&gt;
        </span>[<span style="color: #2b91af">DebuggerBrowsable</span>(<span style="color: #2b91af">DebuggerBrowsableState</span>.Never)]
        <span style="color: blue">private bool </span>isDisposed;

        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">Flag to indicate if this enumerator is in its initial state.</span><span style="color: gray">&lt;/summary&gt;
        </span>[<span style="color: #2b91af">DebuggerBrowsable</span>(<span style="color: #2b91af">DebuggerBrowsableState</span>.Never)]
        <span style="color: blue">private bool </span>isFirst;

        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">The number of partitions in the current selection.</span><span style="color: gray">&lt;/summary&gt;
        </span>[<span style="color: #2b91af">DebuggerBrowsable</span>(<span style="color: #2b91af">DebuggerBrowsableState</span>.Never)]
        <span style="color: blue">private int </span>nc;

        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">An array of values indicating the number of values in the partition at the specified index.</span><span style="color: gray">&lt;/summary&gt;
        </span>[<span style="color: #2b91af">DebuggerBrowsable</span>(<span style="color: #2b91af">DebuggerBrowsableState</span>.Never)]
        <span style="color: blue">private int</span>[] p;

        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">An array of indices indicating to which partition the item at the specified index belongs.</span><span style="color: gray">&lt;/summary&gt;
        </span>[<span style="color: #2b91af">DebuggerBrowsable</span>(<span style="color: #2b91af">DebuggerBrowsableState</span>.Never)]
        <span style="color: blue">private int</span>[] q;

        <span style="color: gray">/// &lt;summary&gt;</span><span style="color: green">The current partition.</span><span style="color: gray">&lt;/summary&gt;
        </span>[<span style="color: #2b91af">DebuggerBrowsable</span>(<span style="color: #2b91af">DebuggerBrowsableState</span>.Never)]
        <span style="color: blue">private </span>T[][] current;

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Creates and initializes an instance of the </span><span style="color: gray">&lt;see cref=&quot;AllPartitionsEnumerator{T}&quot;/&gt; </span><span style="color: green">type.
        </span><span style="color: gray">/// &lt;/summary&gt;
        /// &lt;param name=&quot;items&quot;&gt;</span><span style="color: green">The original set of items over which partitions are enumerated.</span><span style="color: gray">&lt;/param&gt;
        </span><span style="color: blue">public </span>AllPartitionsEnumerator(<span style="color: #2b91af">IEnumerable</span>&lt;T&gt; items)
            : <span style="color: blue">base</span>()
        {
            <span style="color: blue">if </span>(<span style="color: blue">null </span>== items)
            {
                <span style="color: blue">throw new </span><span style="color: #2b91af">ArgumentNullException</span>(<span style="color: #a31515">&quot;items&quot;</span>);
            }

            <span style="color: blue">this</span>.isFirst = <span style="color: blue">true</span>;
            <span style="color: blue">this</span>.items = items.ToArray();
            <span style="color: blue">this</span>.nc = <span style="color: brown">0</span>;
            <span style="color: blue">this</span>.p = <span style="color: blue">new int</span>[<span style="color: blue">this</span>.items.Length];
            <span style="color: blue">this</span>.q = <span style="color: blue">new int</span>[<span style="color: blue">this</span>.items.Length];
            <span style="color: blue">this</span>.current = <span style="color: blue">null</span>;
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Gets the current partition.
        </span><span style="color: gray">/// &lt;/summary&gt;
        </span><span style="color: blue">public </span><span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;T&gt;&gt; Current
        {
            <span style="color: blue">get
            </span>{
                <span style="color: blue">this</span>.CheckIfDisposed();

                <span style="color: blue">return this</span>.current;
            }
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Disposes of this enumerator and releases all resources held by it.
        </span><span style="color: gray">/// &lt;/summary&gt;
        </span><span style="color: blue">public void </span>Dispose()
        {
            <span style="color: blue">if </span>(<span style="color: blue">this</span>.isDisposed)
            {
                <span style="color: blue">return</span>;
            }

            <span style="color: blue">this</span>.isDisposed = <span style="color: blue">true</span>;
            <span style="color: blue">this</span>.items = <span style="color: blue">null</span>;
            <span style="color: blue">this</span>.p = <span style="color: blue">null</span>;
            <span style="color: blue">this</span>.q = <span style="color: blue">null</span>;
            <span style="color: blue">this</span>.nc = <span style="color: brown">0</span>;
            <span style="color: blue">this</span>.current = <span style="color: blue">null</span>;
            <span style="color: blue">this</span>.isFirst = <span style="color: blue">true</span>;
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Gets the current partition.
        </span><span style="color: gray">/// &lt;/summary&gt;
        </span><span style="color: blue">object </span><span style="color: #2b91af">IEnumerator</span>.Current
        {
            <span style="color: blue">get
            </span>{
                <span style="color: blue">return this</span>.Current;
            }
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Selects the next item in the set of all partitions.
        </span><span style="color: gray">/// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;c&gt;</span><span style="color: green">true</span><span style="color: gray">&lt;/c&gt; </span><span style="color: green">if an item was selected; </span><span style="color: gray">&lt;c&gt;</span><span style="color: green">false</span><span style="color: gray">&lt;/c&gt; </span><span style="color: green">if we are past the last element.</span><span style="color: gray">&lt;/returns&gt;
        </span><span style="color: blue">public bool </span>MoveNext()
        {
            <span style="color: blue">this</span>.CheckIfDisposed();

            <span style="color: blue">if </span>(<span style="color: blue">this</span>.isFirst)
            {
                <span style="color: blue">this</span>.isFirst = <span style="color: blue">false</span>;
                <span style="color: blue">this</span>.nc = <span style="color: brown">1</span>;
                <span style="color: blue">this</span>.p[<span style="color: brown">0</span>] = <span style="color: blue">this</span>.items.Length;
                <span style="color: blue">for </span>(<span style="color: blue">int </span>i = <span style="color: brown">0</span>; i &lt; <span style="color: blue">this</span>.items.Length; ++i)
                {
                    <span style="color: blue">this</span>.q[i] = <span style="color: blue">this</span>.nc;
                }
                <span style="color: blue">this</span>.Select();
                <span style="color: blue">return true</span>;
            }

            <span style="color: blue">if </span>(<span style="color: blue">this</span>.nc == <span style="color: blue">this</span>.items.Length )
            {
                <span style="color: blue">return false</span>;
            }

            <span style="color: blue">int </span>n = <span style="color: blue">this</span>.items.Length;
            <span style="color: blue">int </span>m = n;
            <span style="color: blue">int </span>l = <span style="color: blue">this</span>.q[m-<span style="color: brown">1</span>];

            <span style="color: blue">while </span>(<span style="color: blue">this</span>.p[l - <span style="color: brown">1</span>] == <span style="color: brown">1</span>)
            {
                <span style="color: blue">this</span>.q[m - <span style="color: brown">1</span>] = <span style="color: brown">1</span>;
                --m;
                l = <span style="color: blue">this</span>.q[m - <span style="color: brown">1</span>];
            }

            <span style="color: blue">this</span>.nc += m - n;
            <span style="color: blue">this</span>.p[<span style="color: brown">0</span>] = <span style="color: blue">this</span>.p[<span style="color: brown">0</span>] + n - m;

            <span style="color: blue">if </span>(l == <span style="color: blue">this</span>.nc)
            {
                ++<span style="color: blue">this</span>.nc;
                <span style="color: blue">this</span>.p[<span style="color: blue">this</span>.nc - <span style="color: brown">1</span>] = <span style="color: brown">0</span>;
            }

            <span style="color: blue">this</span>.q[m - <span style="color: brown">1</span>] = l + <span style="color: brown">1</span>;
            <span style="color: blue">this</span>.p[l - <span style="color: brown">1</span>] = <span style="color: blue">this</span>.p[l - <span style="color: brown">1</span>] - <span style="color: brown">1</span>;
            <span style="color: blue">this</span>.p[l] = <span style="color: blue">this</span>.p[l] + <span style="color: brown">1</span>;

            <span style="color: blue">this</span>.Select();
            <span style="color: blue">return true</span>;
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Resets this enumerator to its initial state.
        </span><span style="color: gray">/// &lt;/summary&gt;
        </span><span style="color: blue">public void </span>Reset()
        {
            <span style="color: blue">this</span>.CheckIfDisposed();

            <span style="color: blue">this</span>.current = <span style="color: blue">null</span>;
            <span style="color: blue">this</span>.isFirst = <span style="color: blue">true</span>;
            <span style="color: blue">this</span>.isDisposed = <span style="color: blue">false</span>;
            <span style="color: blue">this</span>.p = <span style="color: blue">new int</span>[<span style="color: blue">this</span>.items.Length];
            <span style="color: blue">this</span>.q = <span style="color: blue">new int</span>[<span style="color: blue">this</span>.items.Length];
            <span style="color: blue">this</span>.nc = <span style="color: brown">0</span>;
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Selects the items for the current partition.
        </span><span style="color: gray">/// &lt;/summary&gt;
        </span><span style="color: blue">private void </span>Select()
        {
            <span style="color: blue">this</span>.current = <span style="color: blue">new </span>T[<span style="color: blue">this</span>.nc][];

            <span style="color: blue">for </span>(<span style="color: blue">int </span>i = <span style="color: brown">0</span>; i &lt; <span style="color: blue">this</span>.nc; ++i)
            {
                <span style="color: blue">int </span>k = <span style="color: brown">0</span>;
                <span style="color: blue">this</span>.current[i] = <span style="color: blue">new </span>T[<span style="color: blue">this</span>.p[i]];

                <span style="color: blue">for </span>(<span style="color: blue">int </span>j = <span style="color: brown">0</span>; j &lt; <span style="color: blue">this</span>.items.Length; ++j)
                {
                    <span style="color: blue">if </span>(<span style="color: blue">this</span>.q[j] == i + <span style="color: brown">1</span>)
                    {
                        <span style="color: blue">this</span>.current[i][k] = <span style="color: blue">this</span>.items[j];
                        ++k;
                    }
                }
            }
        }

        <span style="color: gray">/// &lt;summary&gt;
        /// </span><span style="color: green">Checks and throws an exception if this enumerator has been disposed.
        </span><span style="color: gray">/// &lt;/summary&gt;
        </span><span style="color: blue">private void </span>CheckIfDisposed()
        {
            <span style="color: blue">if </span>(<span style="color: blue">this</span>.isDisposed)
            {
                <span style="color: blue">throw new </span><span style="color: #2b91af">ObjectDisposedException</span>(<span style="color: blue">this</span>.GetType().FullName);
            }
        }
    }</pre>

<pre class="code"><span style="color: gray">        /// &lt;summary&gt;
        /// </span><span style="color: green">Retrieves all possible partitions of a set of items.
        </span><span style="color: gray">/// &lt;/summary&gt;
        /// &lt;typeparam name=&quot;T&quot;&gt;</span><span style="color: green">The type of the items in the original set.</span><span style="color: gray">&lt;/typeparam&gt;
        /// &lt;param name=&quot;items&quot;&gt;</span><span style="color: green">The original set of items over which partitions are created.</span><span style="color: gray">&lt;/param&gt;
        /// &lt;returns&gt;</span><span style="color: green">All possible partitions of the items in </span><span style="color: gray">&lt;paramref name=&quot;items&quot;/&gt;</span><span style="color: green">.</span><span style="color: gray">&lt;/returns&gt;
        </span><span style="color: blue">public static </span><span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">IEnumerable</span>&lt;T&gt;&gt;&gt; AllPartitions&lt;T&gt;(<span style="color: blue">this </span><span style="color: #2b91af">IEnumerable</span>&lt;T&gt; items)
        {
            <span style="color: blue">return new </span><span style="color: #2b91af">AllPartitionsEnumerable</span>&lt;T&gt;(items);
        }</pre>

<p>That’s all there is to it. A simple program that generates the 52 partitions of the set {1, 2, 3, 4, 5} is given below:</p>

<pre class="code"><span style="color: blue">            var </span>intset = <span style="color: brown">1</span>.To(<span style="color: brown">5</span>);
            <span style="color: blue">var </span>parts = intset.AllPartitions();

            <span style="color: blue">int </span>j = <span style="color: brown">1</span>;
            <span style="color: blue">foreach </span>(<span style="color: blue">var </span>part <span style="color: blue">in </span>parts)
            {
                <span style="color: blue">var </span>list = part.ToList();

                <span style="color: #2b91af">Console</span>.Write((j++) + <span style="color: #a31515">&quot; - &quot;</span>);
                <span style="color: #2b91af">Console</span>.Write(list[<span style="color: brown">0</span>].ToCsvString());

                <span style="color: blue">for </span>(<span style="color: blue">int </span>i = <span style="color: brown">1</span>; i &lt; list.Count; ++i)
                {
                    <span style="color: #2b91af">Console</span>.Write(<span style="color: #a31515">&quot; : &quot;</span>);
                    <span style="color: #2b91af">Console</span>.Write(list[i].ToCsvString());
                }

                <span style="color: #2b91af">Console</span>.WriteLine();
            }</pre>
<a href="https://11011.net/software/vspaste"></a>

<p>Have fun. </p>

<p><strong>Please note: I hope to make the two implementations posted here as well a few others related to simple combinatorial objects available as an open source library on <a href="https://www.codeplex.com/">CodePlex</a></strong></p>

<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:15d995ea-0dda-4e12-b9cb-74225cd6660c" class="wlWriterEditableSmartContent">Technorati Tags: <a href="https://technorati.com/tags/c%23" rel="tag">c#</a>,<a href="https://technorati.com/tags/partitions" rel="tag">partitions</a>,<a href="https://technorati.com/tags/algorithm" rel="tag">algorithm</a>,<a href="https://technorati.com/tags/combinatorial" rel="tag">combinatorial</a>,<a href="https://technorati.com/tags/combinatorics" rel="tag">combinatorics</a></div>

<p><strong>. I will post details when this is done.</strong></p>

<p><strong></strong></p>

<p><a href="https://11011.net/software/vspaste">&#160;</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Generating All Partitions Of A Set - Fortran 95 Implementation</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/generating-all-partitions-of-a-set-fortran-95-implementation</link>
      <pubDate>Tue, 15 Dec 2009 22:50:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2009/12/15/generating-all-partitions-of-a-set-fortran-95-implementation/</guid>
      <description><![CDATA[Note that the following implementation is a faithful reproduction of the NEXEQU algorithm in the...]]></description>
      <content:encoded><![CDATA[<P><SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium 'Times New Roman'; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(51,51,51); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span><SPAN style="TEXT-ALIGN: left; LINE-HEIGHT: 14px; FONT-STYLE: italic; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 11px" class=Apple-style-span>Note that the following implementation is a faithful reproduction of the NEXEQU algorithm in the book Combinatorial Algorithms For Computers and Calculators by Nijenhuis &amp; Wilf. However, the implementation given in the text has been updated to Fortran 95.</SPAN></SPAN>&nbsp;</P>
<P>The following F95 program generates all partitions of a set. </P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">SUBROUTINE</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> NEXEQU<SPAN style="COLOR: gray">(</SPAN>N<SPAN style="COLOR: gray">,</SPAN> NC<SPAN style="COLOR: gray">,</SPAN> P<SPAN style="COLOR: gray">,</SPAN> Q<SPAN style="COLOR: gray">,</SPAN> MTC<SPAN style="COLOR: gray">)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">INTEGER</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt; mso-no-proof: yes">,</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">DIMENSION</SPAN><SPAN style="COLOR: gray">(</SPAN>N<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: gray">::</SPAN> P<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">INTEGER</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt; mso-no-proof: yes">,</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">DIMENSION</SPAN><SPAN style="COLOR: gray">(</SPAN>N<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: gray">::</SPAN> Q<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">LOGICAL</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> MTC<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">IF</SPAN><SPAN style="COLOR: gray">(</SPAN>MTC<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: blue">GOTO</SPAN> 20<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">10</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>NC<SPAN style="COLOR: gray">=</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">DO</SPAN> 11 I<SPAN style="COLOR: gray">=</SPAN>1<SPAN style="COLOR: gray">,</SPAN>N<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">11</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Q<SPAN style="COLOR: gray">(</SPAN>I<SPAN style="COLOR: gray">)=</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>P<SPAN style="COLOR: gray">(</SPAN>1<SPAN style="COLOR: gray">)=</SPAN>N<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">60</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>MTC<SPAN style="COLOR: gray">=</SPAN>NC <SPAN style="COLOR: gray">.</SPAN><SPAN style="COLOR: blue">NE</SPAN><SPAN style="COLOR: gray">.</SPAN> N<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">RETURN<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">20</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>M<SPAN style="COLOR: gray">=</SPAN>N<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">30</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>L<SPAN style="COLOR: gray">=</SPAN>Q<SPAN style="COLOR: gray">(</SPAN>M<SPAN style="COLOR: gray">)<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">IF</SPAN><SPAN style="COLOR: gray">(</SPAN>P<SPAN style="COLOR: gray">(</SPAN>L<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: gray">.</SPAN><SPAN style="COLOR: blue">NE</SPAN><SPAN style="COLOR: gray">.</SPAN> 1<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: blue">GOTO</SPAN> 40<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>Q<SPAN style="COLOR: gray">(</SPAN>M<SPAN style="COLOR: gray">)=</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>M<SPAN style="COLOR: gray">=</SPAN>M<SPAN style="COLOR: gray">-</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">GOTO</SPAN> 30<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">40</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>NC<SPAN style="COLOR: gray">=</SPAN>NC<SPAN style="COLOR: gray">+</SPAN>M<SPAN style="COLOR: gray">-</SPAN>N<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>P<SPAN style="COLOR: gray">(</SPAN>1<SPAN style="COLOR: gray">)=</SPAN>P<SPAN style="COLOR: gray">(</SPAN>1<SPAN style="COLOR: gray">)+</SPAN>N<SPAN style="COLOR: gray">-</SPAN>m<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">IF</SPAN><SPAN style="COLOR: gray">(</SPAN>L <SPAN style="COLOR: gray">.</SPAN><SPAN style="COLOR: blue">NE</SPAN><SPAN style="COLOR: gray">.</SPAN> NC<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: blue">GOTO</SPAN> 50<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>NC<SPAN style="COLOR: gray">=</SPAN>NC<SPAN style="COLOR: gray">+</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>P<SPAN style="COLOR: gray">(</SPAN>NC<SPAN style="COLOR: gray">)=</SPAN>0<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">50</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Q<SPAN style="COLOR: gray">(</SPAN>M<SPAN style="COLOR: gray">)=</SPAN>L<SPAN style="COLOR: gray">+</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>P<SPAN style="COLOR: gray">(</SPAN>L<SPAN style="COLOR: gray">)=</SPAN>P<SPAN style="COLOR: gray">(</SPAN>L<SPAN style="COLOR: gray">)-</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>P<SPAN style="COLOR: gray">(</SPAN>L<SPAN style="COLOR: gray">+</SPAN>1<SPAN style="COLOR: gray">)=</SPAN>P<SPAN style="COLOR: gray">(</SPAN>L<SPAN style="COLOR: gray">+</SPAN>1<SPAN style="COLOR: gray">)+</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">GOTO</SPAN> 60<o:p></o:p></SPAN></P>
<P><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">END</SPAN>&nbsp;</P>
<P>The following is a test program for the above sub-routine.</P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">SUBROUTINE</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> TESTNEXEQU<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">INTEGER</SPAN><SPAN style="COLOR: gray">,</SPAN> <SPAN style="COLOR: blue">DIMENSION</SPAN><SPAN style="COLOR: gray">(</SPAN>5<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: gray">::</SPAN> P<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">INTEGER</SPAN><SPAN style="COLOR: gray">,</SPAN> <SPAN style="COLOR: blue">DIMENSION</SPAN><SPAN style="COLOR: gray">(</SPAN>5<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: gray">::</SPAN> Q<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">LOGICAL</SPAN> MTC<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">INTEGER</SPAN> L<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">INTEGER</SPAN> NC<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>L <SPAN style="COLOR: gray">=</SPAN> 1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">DO</SPAN> 10 I <SPAN style="COLOR: gray">=</SPAN> 1<SPAN style="COLOR: gray">,</SPAN> 5<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>P<SPAN style="COLOR: gray">(</SPAN>I<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: gray">=</SPAN> 0<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Q<SPAN style="COLOR: gray">(</SPAN>I<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: gray">=</SPAN> 0<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">10</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">CONTINUE<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>MTC <SPAN style="COLOR: gray">=</SPAN> <SPAN style="COLOR: gray">.</SPAN><SPAN style="COLOR: blue">FALSE</SPAN><SPAN style="COLOR: gray">.<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">20</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="COLOR: blue">CONTINUE<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">CALL</SPAN> NEXEQU <SPAN style="COLOR: gray">(</SPAN>5<SPAN style="COLOR: gray">,</SPAN> NC<SPAN style="COLOR: gray">,</SPAN> P<SPAN style="COLOR: gray">,</SPAN> Q<SPAN style="COLOR: gray">,</SPAN> MTC<SPAN style="COLOR: gray">)<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">WRITE</SPAN><SPAN style="COLOR: gray">(*,</SPAN><SPAN style="COLOR: fuchsia">"(I2)"</SPAN><SPAN style="COLOR: gray">,</SPAN> advance<SPAN style="COLOR: gray">=</SPAN><SPAN style="COLOR: fuchsia">"no"</SPAN><SPAN style="COLOR: gray">)</SPAN> L<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">WRITE</SPAN><SPAN style="COLOR: gray">(*,</SPAN><SPAN style="COLOR: fuchsia">"(A)"</SPAN><SPAN style="COLOR: gray">,</SPAN> advance<SPAN style="COLOR: gray">=</SPAN><SPAN style="COLOR: fuchsia">"no"</SPAN><SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: fuchsia">" - "<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">DO</SPAN> 40 J <SPAN style="COLOR: gray">=</SPAN> 1<SPAN style="COLOR: gray">,</SPAN> NC<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">DO</SPAN> 30 I <SPAN style="COLOR: gray">=</SPAN> 1<SPAN style="COLOR: gray">,</SPAN> 5<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">IF</SPAN> <SPAN style="COLOR: gray">(</SPAN>Q<SPAN style="COLOR: gray">(</SPAN>I<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: gray">.</SPAN>EQ<SPAN style="COLOR: gray">.</SPAN> J<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: blue">WRITE</SPAN> <SPAN style="COLOR: gray">(*,</SPAN><SPAN style="COLOR: fuchsia">"(I2), "</SPAN><SPAN style="COLOR: gray">,</SPAN>advance<SPAN style="COLOR: gray">=</SPAN><SPAN style="COLOR: fuchsia">"no"</SPAN><SPAN style="COLOR: gray">)</SPAN> I<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">30</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">CONTINUE<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">WRITE</SPAN><SPAN style="COLOR: gray">(*,</SPAN><SPAN style="COLOR: fuchsia">"(A)"</SPAN><SPAN style="COLOR: gray">,</SPAN> advance<SPAN style="COLOR: gray">=</SPAN><SPAN style="COLOR: fuchsia">"no"</SPAN><SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: fuchsia">" , "<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">40</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">CONTINUE<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">PRINT</SPAN> <SPAN style="COLOR: gray">*<o:p></o:p></SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>L <SPAN style="COLOR: gray">=</SPAN> L<SPAN style="COLOR: gray">+</SPAN>1<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">IF</SPAN> <SPAN style="COLOR: gray">(</SPAN>MTC<SPAN style="COLOR: gray">)</SPAN> <SPAN style="COLOR: blue">GOTO</SPAN> 20<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">END<o:p></o:p></SPAN></P>
<P mce_keep="true"><SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium 'Times New Roman'; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(51,51,51); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span><SPAN style="TEXT-ALIGN: left; LINE-HEIGHT: 14px; FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 11px" class=Apple-style-span><FONT size=2>A C# implementation of the above algorithm will be published soon. </FONT></SPAN></SPAN></P>
<P mce_keep="true"><SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium 'Times New Roman'; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(51,51,51); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span><SPAN style="TEXT-ALIGN: left; LINE-HEIGHT: 14px; FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 11px" class=Apple-style-span><SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium 'Times New Roman'; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(51,51,51); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span><SPAN style="TEXT-ALIGN: left; LINE-HEIGHT: 14px; FONT-STYLE: italic; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 11px" class=Apple-style-span><FONT size=2>THe above code is made available in the hope that it will be useful. Microsoft (my employer) neither endorses nor gaurantees nor assumes any liability for this code. Neither do I.</FONT></SPAN></SPAN></SPAN></SPAN></P>]]></content:encoded>
    </item>
    <item>
      <title>Generating All Permutations - C# Enumerator Implementation</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/generating-all-permutations-c-enumerator-implementation</link>
      <pubDate>Mon, 14 Dec 2009 18:48:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2009/12/14/generating-all-permutations-c-enumerator-implementation/</guid>
      <description><![CDATA[The following code shows the implementation of the all permutations generation algorithm that was...]]></description>
      <content:encoded><![CDATA[<P>The following code shows the implementation of the all permutations generation algorithm that was discussed in the previous blog post in C#.</P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: gray; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>///</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: green; FONT-SIZE: 9.5pt"> </SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: gray; FONT-SIZE: 9.5pt">&lt;summary&gt;</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> An enumeration of all the permuations of a set of items.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;typeparam name="T"&gt;&lt;/typeparam&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">AllPermutationsEnumerable</SPAN>&lt;T&gt; : <SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;<SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt;&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">The set of items over which all permutations are generated.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DebuggerBrowsable</SPAN>(<SPAN style="COLOR: #2b91af">DebuggerBrowsableState</SPAN>.Never)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt; items;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Creates and initializes a new instance of the </SPAN><SPAN style="COLOR: gray">&lt;see cref="AllPermutationsEnumerable{T}"/&gt;</SPAN><SPAN style="COLOR: green"> type.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="items"&gt;</SPAN><SPAN style="COLOR: green">The original set of items over which all permutations are generated.</SPAN><SPAN style="COLOR: gray">&lt;/param&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> AllPermutationsEnumerable(<SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt; items)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: <SPAN style="COLOR: blue">base</SPAN>()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.items = items;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Gets an enumerator to enumerate over the items in this enumeration.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;returns&gt;</SPAN><SPAN style="COLOR: green">An instance of </SPAN><SPAN style="COLOR: gray">&lt;see cref="IEnumerator{T}"/&gt;</SPAN><SPAN style="COLOR: green">.</SPAN><SPAN style="COLOR: gray">&lt;/returns&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: #2b91af">IEnumerator</SPAN>&lt;<SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt;&gt; GetEnumerator()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">AllPermutationsEnumerator</SPAN>&lt;T&gt;(<SPAN style="COLOR: blue">this</SPAN>.items);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Gets an enumerator to enumerate over the items in this enumeration.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;returns&gt;</SPAN><SPAN style="COLOR: green">An instance of </SPAN><SPAN style="COLOR: gray">&lt;see cref="IEnumerator{T}"/&gt;</SPAN><SPAN style="COLOR: green">.</SPAN><SPAN style="COLOR: gray">&lt;/returns&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">IEnumerator</SPAN> <SPAN style="COLOR: #2b91af">IEnumerable</SPAN>.GetEnumerator()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">AllPermutationsEnumerator</SPAN>&lt;T&gt;(<SPAN style="COLOR: blue">this</SPAN>.items);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P>&nbsp;The enumerator is implemented as follows:</P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: gray; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>///</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: green; FONT-SIZE: 9.5pt"> </SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: gray; FONT-SIZE: 9.5pt">&lt;summary&gt;</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Enumerators over all possible permutations of a set of items.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;typeparam name="T"&gt;</SPAN><SPAN style="COLOR: green">The type of the items in the original set.</SPAN><SPAN style="COLOR: gray">&lt;/typeparam&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: #2b91af">AllPermutationsEnumerator</SPAN>&lt;T&gt; : <SPAN style="COLOR: #2b91af">IEnumerator</SPAN>&lt;<SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt;&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">The set of items over which all permutations are generated.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DebuggerBrowsable</SPAN>(<SPAN style="COLOR: #2b91af">DebuggerBrowsableState</SPAN>.Never)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> T[] originalItems;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">Flag to indicate if this enumerator is in its initial state.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DebuggerBrowsable</SPAN>(<SPAN style="COLOR: #2b91af">DebuggerBrowsableState</SPAN>.Never)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">bool</SPAN> isFirst;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">Flag to indicate if this enumerator has been disposed of.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DebuggerBrowsable</SPAN>(<SPAN style="COLOR: #2b91af">DebuggerBrowsableState</SPAN>.Never)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">bool</SPAN> isDisposed;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">The current permutation.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DebuggerBrowsable</SPAN>(<SPAN style="COLOR: #2b91af">DebuggerBrowsableState</SPAN>.Never)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> T[] current;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">The indicates of the items in the original set that are selected for the current permutation.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DebuggerBrowsable</SPAN>(<SPAN style="COLOR: #2b91af">DebuggerBrowsableState</SPAN>.Never)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">int</SPAN>[] indices;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">A state variable used by the permutation algorithm.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DebuggerBrowsable</SPAN>(<SPAN style="COLOR: #2b91af">DebuggerBrowsableState</SPAN>.Never)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">bool</SPAN> even;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><SPAN style="COLOR: green">A state variable used by the permutation algorithm to track whether this enumerator is finished.</SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>[<SPAN style="COLOR: #2b91af">DebuggerBrowsable</SPAN>(<SPAN style="COLOR: #2b91af">DebuggerBrowsableState</SPAN>.Never)]<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">bool</SPAN> isFinished;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Creates and initializes an instance of the </SPAN><SPAN style="COLOR: gray">&lt;see cref="AllPermutationsEnumerator{T}"/&gt;</SPAN><SPAN style="COLOR: green"> type.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="items"&gt;</SPAN><SPAN style="COLOR: green">The set of items over which permutations are to be created.</SPAN><SPAN style="COLOR: gray">&lt;/param&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> AllPermutationsEnumerator(<SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt; items)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>: <SPAN style="COLOR: blue">base</SPAN>()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">null</SPAN> == items)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">throw</SPAN> <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ArgumentNullException</SPAN>(<SPAN style="COLOR: #a31515">"items"</SPAN>);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.originalItems = items.ToArray();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.indices = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: blue">int</SPAN>[<SPAN style="COLOR: blue">this</SPAN>.originalItems.Length];<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">for</SPAN> (<SPAN style="COLOR: blue">int</SPAN> i = <SPAN style="COLOR: brown">0</SPAN>; i &lt; <SPAN style="COLOR: blue">this</SPAN>.indices.Length; ++i)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.indices[i] = i + <SPAN style="COLOR: brown">1</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.current = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.even = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isDisposed = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFirst = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFinished = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Gets the current item referred to by this enumerator.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt; Current<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">get</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.CheckIfDisposed();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">this</SPAN>.current;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Disposes of this enumerator.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">void</SPAN> Dispose()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.isDisposed)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isDisposed = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.originalItems = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.current = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.indices = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.even = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFirst = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFinished = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Gets the current item referred to by this enumerator.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">object</SPAN> <SPAN style="COLOR: #2b91af">IEnumerator</SPAN>.Current<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">get</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">this</SPAN>.Current;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Moves this enumerator to refer to the next item in the enumeration.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;returns&gt;&lt;c&gt;</SPAN><SPAN style="COLOR: green">true</SPAN><SPAN style="COLOR: gray">&lt;/c&gt;</SPAN><SPAN style="COLOR: green"> if a value is available; </SPAN><SPAN style="COLOR: gray">&lt;c&gt;</SPAN><SPAN style="COLOR: green">false</SPAN><SPAN style="COLOR: gray">&lt;/c&gt;</SPAN><SPAN style="COLOR: green"> if the end has been reached.</SPAN><SPAN style="COLOR: gray">&lt;/returns&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">bool</SPAN> MoveNext()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.CheckIfDisposed();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.isFinished)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.isFirst)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.even = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFirst = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.Select();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else</SPAN> <SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.originalItems.Length == <SPAN style="COLOR: brown">1</SPAN>)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.current = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (even)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.even = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.indices.Swap(<SPAN style="COLOR: brown">0</SPAN>, <SPAN style="COLOR: brown">1</SPAN>);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.Select();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (!((<SPAN style="COLOR: blue">this</SPAN>.indices[<SPAN style="COLOR: blue">this</SPAN>.indices.Length-<SPAN style="COLOR: brown">1</SPAN>] != <SPAN style="COLOR: brown">1</SPAN>) || (<SPAN style="COLOR: blue">this</SPAN>.indices[<SPAN style="COLOR: brown">0</SPAN>] != (<SPAN style="COLOR: brown">2</SPAN> + <SPAN style="COLOR: blue">this</SPAN>.indices.Length % <SPAN style="COLOR: brown">2</SPAN>))))<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.indices.Length &lt;= <SPAN style="COLOR: brown">3</SPAN>)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFinished = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFinished = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">for</SPAN> (<SPAN style="COLOR: blue">int</SPAN> i = <SPAN style="COLOR: brown">0</SPAN> ; i &lt; (<SPAN style="COLOR: blue">this</SPAN>.indices.Length - <SPAN style="COLOR: brown">3</SPAN>); ++i)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.indices[i+<SPAN style="COLOR: brown">1</SPAN>] != <SPAN style="COLOR: blue">this</SPAN>.indices[i]+<SPAN style="COLOR: brown">1</SPAN>)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: blue">this</SPAN>.isFinished = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">int</SPAN> s = <SPAN style="COLOR: brown">0</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.even = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">for</SPAN> (<SPAN style="COLOR: blue">int</SPAN> k = <SPAN style="COLOR: brown">1</SPAN>; k &lt; <SPAN style="COLOR: blue">this</SPAN>.indices.Length; ++k)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">int</SPAN> d = <SPAN style="COLOR: brown">0</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">int</SPAN> ia = <SPAN style="COLOR: blue">this</SPAN>.indices[k];<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">int</SPAN> i = k - <SPAN style="COLOR: brown">1</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">for</SPAN> (<SPAN style="COLOR: blue">int</SPAN> j = <SPAN style="COLOR: brown">0</SPAN>; j &lt;= i; ++j)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.indices[j] &gt; ia)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>++d;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>s += d;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (d != (i+<SPAN style="COLOR: brown">1</SPAN>) * (s % <SPAN style="COLOR: brown">2</SPAN>))<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">int</SPAN> l = <SPAN style="COLOR: brown">0</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">int</SPAN> m = ((s + <SPAN style="COLOR: brown">1</SPAN>) % <SPAN style="COLOR: brown">2</SPAN>) * (<SPAN style="COLOR: blue">this</SPAN>.indices.Length + <SPAN style="COLOR: brown">1</SPAN>);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">for</SPAN> (<SPAN style="COLOR: blue">int</SPAN> j = <SPAN style="COLOR: brown">0</SPAN>; j &lt;= i; ++j)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.Sign(<SPAN style="COLOR: brown">1</SPAN>, <SPAN style="COLOR: blue">this</SPAN>.indices[j] - ia) != <SPAN style="COLOR: blue">this</SPAN>.Sign(<SPAN style="COLOR: brown">1</SPAN>, <SPAN style="COLOR: blue">this</SPAN>.indices[j] - m))<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>m = <SPAN style="COLOR: blue">this</SPAN>.indices[j];<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>l = j;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.indices[l] = ia;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.indices[k] = m;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.even = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.Select();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">break</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Simulates the fortran SIGN function that computes the absolute of the parameter </SPAN><SPAN style="COLOR: gray">&lt;paramref name="x"/&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> and then assigns the sign of the parameter </SPAN><SPAN style="COLOR: gray">&lt;paramref name="y"/&gt;</SPAN><SPAN style="COLOR: green"> to </SPAN><SPAN style="COLOR: gray">&lt;paramref name="x"/&gt;</SPAN><SPAN style="COLOR: green"> and returns</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> this new value.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="x"&gt;</SPAN><SPAN style="COLOR: green">The value to sign.</SPAN><SPAN style="COLOR: gray">&lt;/param&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="y"&gt;</SPAN><SPAN style="COLOR: green">The value that determines the sign.</SPAN><SPAN style="COLOR: gray">&lt;/param&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;returns&gt;&lt;paramref name="x"/&gt;</SPAN><SPAN style="COLOR: green"> signed by </SPAN><SPAN style="COLOR: gray">&lt;paramref name="y"/&gt;</SPAN><SPAN style="COLOR: green">.</SPAN><SPAN style="COLOR: gray">&lt;/returns&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">int</SPAN> Sign(<SPAN style="COLOR: blue">int</SPAN> x, <SPAN style="COLOR: blue">int</SPAN> y)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (y &gt;= <SPAN style="COLOR: brown">0</SPAN>)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>x = <SPAN style="COLOR: #2b91af">Math</SPAN>.Abs(x);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>x = -<SPAN style="COLOR: brown">1</SPAN> * <SPAN style="COLOR: #2b91af">Math</SPAN>.Abs(x);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> x;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Selects the items in the current permutation based on the computed indicies of the items</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> to be selected.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">void</SPAN> Select()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.current = <SPAN style="COLOR: blue">new</SPAN> T[<SPAN style="COLOR: blue">this</SPAN>.originalItems.Length];<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">for</SPAN> (<SPAN style="COLOR: blue">int</SPAN> i = <SPAN style="COLOR: brown">0</SPAN>; i &lt; <SPAN style="COLOR: blue">this</SPAN>.indices.Length; ++i)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.current[i] = <SPAN style="COLOR: blue">this</SPAN>.originalItems[<SPAN style="COLOR: blue">this</SPAN>.indices[i] - <SPAN style="COLOR: brown">1</SPAN>];<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Resets this enumerator to the initial state.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">void</SPAN> Reset()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.CheckIfDisposed();<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">for</SPAN> (<SPAN style="COLOR: blue">int</SPAN> i = <SPAN style="COLOR: brown">0</SPAN>; i &lt; <SPAN style="COLOR: blue">this</SPAN>.indices.Length; ++i)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.indices[i] = i + <SPAN style="COLOR: brown">1</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.current = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.even = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isDisposed = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFirst = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.isFinished = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Checks and throws an exception if this enumerator has been disposed.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">void</SPAN> CheckIfDisposed()<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (<SPAN style="COLOR: blue">this</SPAN>.isDisposed)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">throw</SPAN> <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ObjectDisposedException</SPAN>(<SPAN style="COLOR: blue">this</SPAN>.GetType().FullName);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P>Granted, that is probably no thte cleanest or the best implementation, but hey, it does the job. And of course, an extension method to make this available to any enumeration:</P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> Retrieves all possible permutations of a set of items.</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;/summary&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;typeparam name="T"&gt;</SPAN><SPAN style="COLOR: green">The type of the items in the original set.</SPAN><SPAN style="COLOR: gray">&lt;/typeparam&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;param name="items"&gt;</SPAN><SPAN style="COLOR: green">The original set of items over which permutations are created.</SPAN><SPAN style="COLOR: gray">&lt;/param&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: gray">///</SPAN><SPAN style="COLOR: green"> </SPAN><SPAN style="COLOR: gray">&lt;returns&gt;</SPAN><SPAN style="COLOR: green">All permutations of the items in </SPAN><SPAN style="COLOR: gray">&lt;paramref name="items"/&gt;</SPAN><SPAN style="COLOR: green">.</SPAN><SPAN style="COLOR: gray">&lt;/returns&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">static</SPAN> <SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;<SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt;&gt; AllPermutations&lt;T&gt;(<SPAN style="COLOR: blue">this</SPAN> <SPAN style="COLOR: #2b91af">IEnumerable</SPAN>&lt;T&gt; items)<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">AllPermutationsEnumerable</SPAN>&lt;T&gt;(items);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P mce_keep="true">
<P mce_keep="true">The only problem with the above code is that it does not take care of permutations of sets with repetitions. </P>
<P mce_keep="true"><EM>THe above code is made available in the hope that it will be useful. Microsoft (my employer) neither endorses nor gaurantees nor assumes any liability for this code. Neither do I. </EM></P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Generating All Permutations - Fortran 95 Implementation</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/generating-all-permutations-fortran-95-implementation</link>
      <pubDate>Sun, 13 Dec 2009 13:52:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2009/12/13/generating-all-permutations-fortran-95-implementation/</guid>
      <description><![CDATA[Note that the following implementation is a faithful reproduction of the NEXPER algorithm in the...]]></description>
      <content:encoded><![CDATA[<P><EM>Note that the following implementation is a faithful reproduction of the NEXPER algorithm in the book Combinatorial Algorithms For Computers and Calculators by Nijenhuis &amp; Wilf. However, the implementation given in the text has been updated to Fortran 95. </EM></P>
<P><CODE>SUBROUTINE NEXPER(N, A, MTC, EVEN)<BR>INTEGER N<BR>INTEGER, DIMENSION(N) :: A<BR>INTEGER S, D, NM3, IA, I1, L<BR>LOGICAL MTC, EVEN<BR>&nbsp;&nbsp;&nbsp; IF (MTC) GOTO 10<BR>&nbsp;&nbsp;&nbsp; NM3 = N-3<BR>&nbsp;&nbsp;&nbsp; DO 1 I=1,N<BR>1&nbsp;&nbsp; A(I)=I<BR>&nbsp;&nbsp;&nbsp; MTC=.TRUE.<BR>5&nbsp;&nbsp; EVEN=.TRUE.<BR>&nbsp;&nbsp;&nbsp; IF(N .EQ. 1) GOTO 8<BR>6&nbsp;&nbsp; IF(A(N) .NE. 1 .OR. A(1) .NE. 2+MOD(N,2)) RETURN<BR>&nbsp;&nbsp;&nbsp; IF(N .LE. 3) GOTO 8<BR>&nbsp;&nbsp;&nbsp; DO 7 I=1,NM3<BR>&nbsp;&nbsp;&nbsp; IF(A(I+1) .NE. A(I)+1) RETURN<BR>7&nbsp;&nbsp; CONTINUE<BR>8&nbsp;&nbsp; MTC=.FALSE.<BR>&nbsp;&nbsp;&nbsp; RETURN<BR>10&nbsp; IF(N .EQ. 1) GOTO 27<BR>&nbsp;&nbsp;&nbsp; IF(.NOT. EVEN) GOTO 20<BR>&nbsp;&nbsp;&nbsp;&nbsp;IA=A(1)<BR>&nbsp;&nbsp; &nbsp;A(1)=A(2)<BR>&nbsp;&nbsp;&nbsp; A(2)=IA<BR>&nbsp;&nbsp;&nbsp; EVEN=.FALSE.<BR>&nbsp;&nbsp;&nbsp; GOTO 6<BR>20&nbsp; S=0<BR>&nbsp;&nbsp;&nbsp; DO 26 I1=2,N<BR>25&nbsp; IA=A(I1)<BR>&nbsp;&nbsp;&nbsp; I=I1-1<BR>&nbsp;&nbsp;&nbsp; D=0<BR>&nbsp;&nbsp;&nbsp; DO 30 J=1,I<BR>30&nbsp; IF(A(J) .GT. IA) D=D+1<BR>&nbsp;&nbsp;&nbsp; S=D+S<BR>&nbsp;&nbsp;&nbsp; IF(D .NE. I*MOD(S,2)) GOTO 35<BR>26&nbsp; CONTINUE<BR>27&nbsp; A(1)=0<BR>&nbsp;&nbsp;&nbsp; GOTO 8<BR>35&nbsp; M=MOD(S+1,2)*(N+1)<BR>&nbsp;&nbsp;&nbsp; DO&nbsp;40 J=1,I<BR>&nbsp;&nbsp;&nbsp; IF(ISIGN(1,A(J)-IA) .EQ. ISIGN(1,A(J)-M)) GOTO 40<BR>&nbsp;&nbsp;&nbsp; M=A(J)<BR>&nbsp;&nbsp;&nbsp; L=J<BR>40&nbsp; CONTINUE<BR>&nbsp;&nbsp;&nbsp; A(L)=IA<BR>&nbsp;&nbsp;&nbsp; A(I1)=M<BR>&nbsp;&nbsp;&nbsp; EVEN=.TRUE.<BR>&nbsp;&nbsp;&nbsp; RETURN<BR>END<BR><BR>SUBROUTINE TESTNEXPER<BR>&nbsp;&nbsp;&nbsp;&nbsp;INTEGER, DIMENSION(5) :: IN<BR>&nbsp;&nbsp;&nbsp; LOGICAL MTC<BR>&nbsp;&nbsp;&nbsp; LOGICAL EVEN<BR>&nbsp;&nbsp;&nbsp;&nbsp;DO 10 I = 1, 5<BR>&nbsp;&nbsp;&nbsp; IN(I) = I<BR>10&nbsp; CONTINUE<BR>&nbsp;&nbsp;&nbsp; MTC = .FALSE.<BR>20&nbsp; CONTINUE<BR>&nbsp;&nbsp;&nbsp; CALL NEXPER (5, IN, MTC, EVEN)<BR>&nbsp;&nbsp;&nbsp; DO 30 I = 1, 5<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WRITE (*,"(I2), ",advance="no") IN(I)<BR>30&nbsp; CONTINUE<BR>&nbsp;&nbsp;&nbsp; PRINT *<BR>&nbsp;&nbsp;&nbsp; IF (MTC) GOTO 20<BR>END<BR></CODE><CODE></P>
<P mce_keep="true"><FONT face=arial,helvetica,sans-serif>A C# implementation of the above algorithm will be published soon.</FONT></P></CODE>]]></content:encoded>
    </item>
    <item>
      <title>How do I retrieve a list of all web services on a machine?</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/how-do-i-retrieve-a-list-of-all-web-services-on-a-machine</link>
      <pubDate>Tue, 27 Oct 2009 16:16:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2009/10/27/how-do-i-retrieve-a-list-of-all-web-services-on-a-machine/</guid>
      <description><![CDATA[If I have a machine say FOO and I want to retrieve all web services on that machine how do I do...]]></description>
      <content:encoded><![CDATA[<P>If I have a machine say FOO and I want to retrieve all web services on that machine how do I do it?</P>
<P>I can use WS-Discovery and I know how to do this with the .NET 4.0 Discovery API. However, the only sample I could find is multicast, which in my use case is not sufficient because:-</P>
<OL>
<LI>I already know which machines may be hosting the service.</LI>
<LI>UDP multicast is going to be unreliable given that I have potentially many machines on the network, but I am targetting only a limited subset.</LI>
<LI>Managed mode with a proxy is not going to work either, because this is yet another "pre-requisite" I have to setup.</LI></OL>
<P>This should be easy right? Startup, send a message to&nbsp;one or more&nbsp;machines and wait for a specified period of time for a reply.</P>
<P>For some reason, however, that doesn't suffice. Any ideas?</P>]]></content:encoded>
    </item>
    <item>
      <title>Redirecting Standard Error &amp; Output For A Child Process</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/redirecting-standard-error-output-for-a-child-process</link>
      <pubDate>Mon, 05 Oct 2009 20:09:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2009/10/05/redirecting-standard-error-output-for-a-child-process/</guid>
      <description><![CDATA[If your application or library wants to kick off a child process C and you want to redirect standard...]]></description>
      <content:encoded><![CDATA[<p>If your application or library wants to kick off a child process C and you want to redirect standard output and error, this is what you do:</p><p><span class="Apple-style-span" style="white-space: pre; "><span style="color: #2b91af;">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    ProcessStartInfo</span> psi = <span style="color: blue;">new</span> <span style="color: #2b91af;">ProcessStartInfo</span>();</span></p><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"><font class="Apple-style-span" color="#2B91AF"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Courier New'; white-space: normal; "><pre style="font-family: Arial, Helvetica, sans-serif; font-size: 10pt; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-tab-span" style="white-space: pre; "><font class="Apple-style-span" color="#2B91AF">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </font></span></pre></span></font></pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>psi.Arguments = <span style="color: blue;">this</span>.CreateArgumentsString();</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>psi.FileName = <span style="color: blue;">this</span>.ImageFile;</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>psi.CreateNoWindow = <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>psi.RedirectStandardError = <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>psi.RedirectStandardInput = <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>psi.RedirectStandardOutput = <span style="color: blue;">true</span>;</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>psi.WorkingDirectory = <span style="color: blue;">this</span>.WorkingDirectory;</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>psi.UseShellExecute = <span style="color: blue;">false</span>;</pre><pre style="margin: 0px;"><font class="Apple-style-span" color="#2B91AF"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Courier New'; white-space: normal; "><pre style="font-family: Arial, Helvetica, sans-serif; font-size: 10pt; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-tab-span" style="white-space: pre; "><font class="Apple-style-span" color="#2B91AF">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </font></span></pre></span></font></pre><pre style="margin: 0px;"><span style="color: #2b91af;">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    Process</span> p = <span style="color: blue;">new</span> <span style="color: #2b91af;">Process</span>();</pre><pre style="margin: 0px;"><font class="Apple-style-span" color="#2B91AF"><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Courier New'; white-space: normal; "><pre style="font-family: Arial, Helvetica, sans-serif; font-size: 10pt; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span class="Apple-tab-span" style="white-space: pre; "><font class="Apple-style-span" color="#2B91AF">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </font></span></pre></span></font></pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>p.OutputDataReceived += <span style="color: blue;">new</span> <span style="color: #2b91af;">DataReceivedEventHandler</span>(ProcessOutputDataReceived);</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>p.ErrorDataReceived += <span style="color: blue;">new</span> <span style="color: #2b91af;">DataReceivedEventHandler</span>(ProcessErrorDataReceived);</pre><pre style="margin: 0px;"><span class="Apple-style-span" style="color: rgb(43, 145, 175); ">	<span class="Apple-tab-span" style="white-space: pre; ">	</span>    </span>p.StartInfo = psi;</pre><pre style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#2B91AF">	<span class="Apple-tab-span" style="white-space:pre">	</span>    </font></span>p.EnableRaisingEvents = <span style="color: blue;">true</span>;</pre></div><p><span class="Apple-style-span" style="white-space: pre; "><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#2B91AF">	<span class="Apple-tab-span" style="white-space:pre">	</span>    </font></span>p.Start();</span></p><p><span class="Apple-style-span" style="white-space: pre; "><span class="Apple-tab-span" style="white-space:pre">		</span>    p.BeginErrorReadLine();</span></p><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#2B91AF">	<span class="Apple-tab-span" style="white-space:pre">	</span>    </font></span>p.BeginOutputReadLine();</pre><pre style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" color="#2B91AF">	<span class="Apple-tab-span" style="white-space:pre">	</span>    </font></span>p.WaitForExit();</pre><pre style="margin: 0px;">&nbsp;</pre><pre style="margin: 0px;">That will redirect output and error data from your child process to the console asynchronously (er, depending on the implementation of ProcessOutputDataReceived and ProcessErrorDataReceived). Which is good because if the invoking application is a console application and you want to see the output/error in real time then you want it to work like this.</pre></div>]]></content:encoded>
    </item>
    <item>
      <title>Debuggee Process Terminated Abruptly</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/debuggee-process-terminated-abruptly</link>
      <pubDate>Fri, 02 Oct 2009 12:32:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2009/10/02/debuggee-process-terminated-abruptly/</guid>
      <description><![CDATA[I have been getting this error lately when trying to debug a test. I would be stepping over line by...]]></description>
      <content:encoded><![CDATA[<P>I have been getting this error lately when trying to debug a test. I would be stepping over line by line and suddenly the debuggee process will exit suddenly. The proces exits with the error code is&nbsp;<FONT face="Courier New">-2147023895 (0x800703e9).</FONT>&nbsp; There are only a few reasons why a process would exit suddenly. One of them is a stack overflow and this error code is exactly that. </P>
<P>But, I don't have any recursive or other code that could cause a stack overflow. So what could be the problem? Apparently, when you have implicit function evaluation is enabled in VS (Tools -&gt; Options -&gt; Debugging) and the evaluated function/property has a recursion (type?) this could happen. Another reason it could happen is if you have the "DebuggerDisplay" attribute on your type. I do this often because I would like to glance at the instance and get an idea of what it is. Maybe this is the problem? It is in fact the problem. </P>]]></content:encoded>
    </item>
    <item>
      <title>IGNORE_DUP_KEY, LINQ &amp; Deadlocks</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/ignore_dup_key-linq-deadlocks</link>
      <pubDate>Tue, 11 Nov 2008 22:16:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2008/11/11/ignore_dup_key-linq-deadlocks/</guid>
      <description><![CDATA[I&nbsp;am working on a project.&nbsp;The idea is to persist stack trace information for each test...]]></description>
      <content:encoded><![CDATA[<P>I&nbsp;am working on a project.&nbsp;The idea is to persist stack trace information for each test failure in a database so that we can automate/facilitate analysis of related test failures. For example, we can query for all tests that fail at a particular method or that have a subset of the given strack trace and so on. This allows testers to easily group together multiple test failures that arise due to the same reason and classify them as a single failure.</P>
<P>As I implemented these changes, I used LINQ from the beginning. But, recently an issue arose when I was testing reporting with multiple parallel test agents. The problem was that the entries for the same entity inserted twice. This would break analysis and so I created a unique index key on the columns that uniquely identify an entity. I set the IGNORE_DUP_KEY option on this index as well. Unfortunately, LINQ can't handle this. LINQ won't gracefully handle a duplicate insert. </P>
<P>On a side note, to handle this, I create a stored procedure to perform the check and insert within a serializable transaction and invoked this via LINQ. However, again, when going at it with multiple test agents, this approach breaks down because the database server kills one of the transaction as a deadlock victim. This will be propagated as a SqlException with an error code of 1209 which you may want to handle if you want to retry the submit after some random interval.</P>]]></content:encoded>
    </item>
    <item>
      <title>Implementing a Custom Test Type - Part 3 (Dissecting the MyTest Sample - 1)</title>
      <link>https://docs.microsoft.com/archive/blogs/updownroundnround/implementing-a-custom-test-type-part-3-dissecting-the-mytest-sample-1</link>
      <pubDate>Fri, 19 Sep 2008 20:13:00 GMT</pubDate>
      <dc:creator><![CDATA[VijaiKalyan]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/updownroundnround/2008/09/19/implementing-a-custom-test-type-part-3-dissecting-the-mytest-sample-1/</guid>
      <description><![CDATA[This post deals with the MyTest sample. I will start at the beginning of time. 
Pre Requisites
I...]]></description>
      <content:encoded><![CDATA[<P>This post deals with the MyTest sample. I will start at the beginning of time. </P>
<P><U>Pre Requisites</U></P>
<P>I copied over the MyTest folder in the Visual Studio SDK to a separate directory. In doing so, I discovered some issues with the MyTestUI project. You will have to open up the MyTestUI.vcproj file in NotePad and replace the "..\..\..\..\VisualStudioIntegration\" parts with <STRONG>PATHTOVSSDK</STRONG>\VisualStudioIntegration. This ensures that the copied over solution builds correctly.</P>
<P>Another point to note is that I moved the entire solution to a location with no spaces in the path. That way I don't have deal with all the long name related issues. (As a matter of principle, I usually never put anything except the default stuff in locations with spaces in the name.)</P>
<P>A&nbsp;third&nbsp;action is to go through the registry searching for anything with a "MyTest*" entry and deleting them. This ensures that we are starting with a clean slate.</P>
<P>Finally, open up MyTest.sln. Fix your solution configuration. MyTestUI.vcproj is a VC project targeting Win32 and MyTest.csproj is a C# project targeting AnyCPU. Make sure your solution has only one configuration that builds the (Debug, Release) configurations with the Win32 and AnyCPU platforms for these projects respectively.</P>
<P>OK. Now open up MyTest.sln and rebuild everything. Open a VS command shell (in your Start menu folder for Visual Studio 2008, there is a Visual Studio Tools folder). Navigate to the location you copied the MyTest sample to and execute <FONT face="courier new,courier">deploy.bat Debug</FONT>. That should succeed.</P>
<P>Then execute <FONT face="courier new,courier">devenv /setup</FONT>. This ensures that your project and item templates are rebuilt. Start up Visual Studio, create a test project. Then add a new test item and voila! you should see <FONT face="courier new,courier">MyTest</FONT> and a <FONT face="courier new,courier">MyTest Wizard</FONT> entry in the test types dialog.</P>
<P>More on what happens after you select the <FONT face="courier new,courier">MyTest</FONT> test in the next post.</P>]]></content:encoded>
    </item>
  </channel>
</rss>