commons-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brit...@apache.org
Subject svn commit: r949214 [13/35] - in /websites/production/commons/content/sandbox/commons-text: ./ apidocs/ apidocs/org/apache/commons/text/diff/ apidocs/org/apache/commons/text/diff/class-use/ apidocs/org/apache/commons/text/names/ apidocs/org/apache/comm...
Date Sun, 26 Apr 2015 10:18:28 GMT
Modified: websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/StringsComparator.html
==============================================================================
--- websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/StringsComparator.html (original)
+++ websites/production/commons/content/sandbox/commons-text/apidocs/src-html/org/apache/commons/text/diff/StringsComparator.html Sun Apr 26 10:18:25 2015
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html lang="en">
+<html lang="de">
 <head>
 <title>Source code</title>
 <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
@@ -56,288 +56,286 @@
 <span class="sourceLineNo">048</span> * @see EditScript<a name="line.48"></a>
 <span class="sourceLineNo">049</span> * @see EditCommand<a name="line.49"></a>
 <span class="sourceLineNo">050</span> * @see CommandVisitor<a name="line.50"></a>
-<span class="sourceLineNo">051</span> *<a name="line.51"></a>
-<span class="sourceLineNo">052</span> * @since 1.0<a name="line.52"></a>
-<span class="sourceLineNo">053</span> */<a name="line.53"></a>
-<span class="sourceLineNo">054</span>public class StringsComparator {<a name="line.54"></a>
-<span class="sourceLineNo">055</span><a name="line.55"></a>
-<span class="sourceLineNo">056</span>    /**<a name="line.56"></a>
-<span class="sourceLineNo">057</span>     * First character sequence.<a name="line.57"></a>
-<span class="sourceLineNo">058</span>     */<a name="line.58"></a>
-<span class="sourceLineNo">059</span>    private final String left;<a name="line.59"></a>
-<span class="sourceLineNo">060</span>    /**<a name="line.60"></a>
-<span class="sourceLineNo">061</span>     * Second character sequence.<a name="line.61"></a>
-<span class="sourceLineNo">062</span>     */<a name="line.62"></a>
-<span class="sourceLineNo">063</span>    private final String right;<a name="line.63"></a>
-<span class="sourceLineNo">064</span>    /**<a name="line.64"></a>
-<span class="sourceLineNo">065</span>     * Temporary array.<a name="line.65"></a>
-<span class="sourceLineNo">066</span>     */<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    private final int[] vDown;<a name="line.67"></a>
-<span class="sourceLineNo">068</span>    /**<a name="line.68"></a>
-<span class="sourceLineNo">069</span>     * Temporary array.<a name="line.69"></a>
-<span class="sourceLineNo">070</span>     */<a name="line.70"></a>
-<span class="sourceLineNo">071</span>    private final int[] vUp;<a name="line.71"></a>
-<span class="sourceLineNo">072</span><a name="line.72"></a>
-<span class="sourceLineNo">073</span>    /**<a name="line.73"></a>
-<span class="sourceLineNo">074</span>     * Simple constructor.<a name="line.74"></a>
-<span class="sourceLineNo">075</span>     * &lt;p&gt;<a name="line.75"></a>
-<span class="sourceLineNo">076</span>     * Creates a new instance of StringsComparator.<a name="line.76"></a>
-<span class="sourceLineNo">077</span>     * &lt;/p&gt;<a name="line.77"></a>
-<span class="sourceLineNo">078</span>     * &lt;p&gt;<a name="line.78"></a>
-<span class="sourceLineNo">079</span>     * It is &lt;em&gt;guaranteed&lt;/em&gt; that the comparisons will always be done as<a name="line.79"></a>
-<span class="sourceLineNo">080</span>     * &lt;code&gt;o1.equals(o2)&lt;/code&gt; where &lt;code&gt;o1&lt;/code&gt; belongs to the first<a name="line.80"></a>
-<span class="sourceLineNo">081</span>     * sequence and &lt;code&gt;o2&lt;/code&gt; belongs to the second sequence. This can be<a name="line.81"></a>
-<span class="sourceLineNo">082</span>     * important if subclassing is used for some elements in the first sequence<a name="line.82"></a>
-<span class="sourceLineNo">083</span>     * and the &lt;code&gt;equals&lt;/code&gt; method is specialized.<a name="line.83"></a>
-<span class="sourceLineNo">084</span>     * &lt;/p&gt;<a name="line.84"></a>
-<span class="sourceLineNo">085</span>     *<a name="line.85"></a>
-<span class="sourceLineNo">086</span>     * @param left first character sequence to be compared<a name="line.86"></a>
-<span class="sourceLineNo">087</span>     * @param right second character sequence to be compared<a name="line.87"></a>
-<span class="sourceLineNo">088</span>     */<a name="line.88"></a>
-<span class="sourceLineNo">089</span>    public StringsComparator(String left, String right) {<a name="line.89"></a>
-<span class="sourceLineNo">090</span>        this.left = left;<a name="line.90"></a>
-<span class="sourceLineNo">091</span>        this.right = right;<a name="line.91"></a>
-<span class="sourceLineNo">092</span><a name="line.92"></a>
-<span class="sourceLineNo">093</span>        final int size = left.length() + right.length() + 2;<a name="line.93"></a>
-<span class="sourceLineNo">094</span>        vDown = new int[size];<a name="line.94"></a>
-<span class="sourceLineNo">095</span>        vUp   = new int[size];<a name="line.95"></a>
-<span class="sourceLineNo">096</span>    }<a name="line.96"></a>
-<span class="sourceLineNo">097</span><a name="line.97"></a>
-<span class="sourceLineNo">098</span>    /**<a name="line.98"></a>
-<span class="sourceLineNo">099</span>     * Get the {@link EditScript} object.<a name="line.99"></a>
-<span class="sourceLineNo">100</span>     * &lt;p&gt;<a name="line.100"></a>
-<span class="sourceLineNo">101</span>     * It is guaranteed that the objects embedded in the {@link InsertCommand<a name="line.101"></a>
-<span class="sourceLineNo">102</span>     * insert commands} come from the second sequence and that the objects<a name="line.102"></a>
-<span class="sourceLineNo">103</span>     * embedded in either the {@link DeleteCommand delete commands} or<a name="line.103"></a>
-<span class="sourceLineNo">104</span>     * {@link KeepCommand keep commands} come from the first sequence. This can<a name="line.104"></a>
-<span class="sourceLineNo">105</span>     * be important if subclassing is used for some elements in the first<a name="line.105"></a>
-<span class="sourceLineNo">106</span>     * sequence and the &lt;code&gt;equals&lt;/code&gt; method is specialized.<a name="line.106"></a>
-<span class="sourceLineNo">107</span>     * &lt;/p&gt;<a name="line.107"></a>
-<span class="sourceLineNo">108</span>     *<a name="line.108"></a>
-<span class="sourceLineNo">109</span>     * @return the edit script resulting from the comparison of the two<a name="line.109"></a>
-<span class="sourceLineNo">110</span>     *         sequences<a name="line.110"></a>
-<span class="sourceLineNo">111</span>     */<a name="line.111"></a>
-<span class="sourceLineNo">112</span>    public EditScript&lt;Character&gt; getScript() {<a name="line.112"></a>
-<span class="sourceLineNo">113</span>        final EditScript&lt;Character&gt; script = new EditScript&lt;Character&gt;();<a name="line.113"></a>
-<span class="sourceLineNo">114</span>        buildScript(0, left.length(), 0, right.length(), script);<a name="line.114"></a>
-<span class="sourceLineNo">115</span>        return script;<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    }<a name="line.116"></a>
-<span class="sourceLineNo">117</span><a name="line.117"></a>
-<span class="sourceLineNo">118</span>    /**<a name="line.118"></a>
-<span class="sourceLineNo">119</span>     * Build an edit script.<a name="line.119"></a>
-<span class="sourceLineNo">120</span>     *<a name="line.120"></a>
-<span class="sourceLineNo">121</span>     * @param start1  the begin of the first sequence to be compared<a name="line.121"></a>
-<span class="sourceLineNo">122</span>     * @param end1  the end of the first sequence to be compared<a name="line.122"></a>
-<span class="sourceLineNo">123</span>     * @param start2  the begin of the second sequence to be compared<a name="line.123"></a>
-<span class="sourceLineNo">124</span>     * @param end2  the end of the second sequence to be compared<a name="line.124"></a>
-<span class="sourceLineNo">125</span>     * @param script the edited script<a name="line.125"></a>
-<span class="sourceLineNo">126</span>     */<a name="line.126"></a>
-<span class="sourceLineNo">127</span>    private void buildScript(final int start1, final int end1, final int start2, final int end2,<a name="line.127"></a>
-<span class="sourceLineNo">128</span>            final EditScript&lt;Character&gt; script) {<a name="line.128"></a>
-<span class="sourceLineNo">129</span>        final Snake middle = getMiddleSnake(start1, end1, start2, end2);<a name="line.129"></a>
-<span class="sourceLineNo">130</span><a name="line.130"></a>
-<span class="sourceLineNo">131</span>        if (middle == null<a name="line.131"></a>
-<span class="sourceLineNo">132</span>                || middle.getStart() == end1 &amp;&amp; middle.getDiag() == end1 - end2<a name="line.132"></a>
-<span class="sourceLineNo">133</span>                || middle.getEnd() == start1 &amp;&amp; middle.getDiag() == start1 - start2) {<a name="line.133"></a>
-<span class="sourceLineNo">134</span><a name="line.134"></a>
-<span class="sourceLineNo">135</span>            int i = start1;<a name="line.135"></a>
-<span class="sourceLineNo">136</span>            int j = start2;<a name="line.136"></a>
-<span class="sourceLineNo">137</span>            while (i &lt; end1 || j &lt; end2) {<a name="line.137"></a>
-<span class="sourceLineNo">138</span>                if (i &lt; end1 &amp;&amp; j &lt; end2 &amp;&amp; left.charAt(i) == right.charAt(j)) {<a name="line.138"></a>
-<span class="sourceLineNo">139</span>                    script.append(new KeepCommand&lt;Character&gt;(left.charAt(i)));<a name="line.139"></a>
-<span class="sourceLineNo">140</span>                    ++i;<a name="line.140"></a>
-<span class="sourceLineNo">141</span>                    ++j;<a name="line.141"></a>
-<span class="sourceLineNo">142</span>                } else {<a name="line.142"></a>
-<span class="sourceLineNo">143</span>                    if (end1 - start1 &gt; end2 - start2) {<a name="line.143"></a>
-<span class="sourceLineNo">144</span>                        script.append(new DeleteCommand&lt;Character&gt;(left.charAt(i)));<a name="line.144"></a>
-<span class="sourceLineNo">145</span>                        ++i;<a name="line.145"></a>
-<span class="sourceLineNo">146</span>                    } else {<a name="line.146"></a>
-<span class="sourceLineNo">147</span>                        script.append(new InsertCommand&lt;Character&gt;(right.charAt(j)));<a name="line.147"></a>
-<span class="sourceLineNo">148</span>                        ++j;<a name="line.148"></a>
-<span class="sourceLineNo">149</span>                    }<a name="line.149"></a>
-<span class="sourceLineNo">150</span>                }<a name="line.150"></a>
-<span class="sourceLineNo">151</span>            }<a name="line.151"></a>
+<span class="sourceLineNo">051</span> */<a name="line.51"></a>
+<span class="sourceLineNo">052</span>public class StringsComparator {<a name="line.52"></a>
+<span class="sourceLineNo">053</span><a name="line.53"></a>
+<span class="sourceLineNo">054</span>    /**<a name="line.54"></a>
+<span class="sourceLineNo">055</span>     * First character sequence.<a name="line.55"></a>
+<span class="sourceLineNo">056</span>     */<a name="line.56"></a>
+<span class="sourceLineNo">057</span>    private final String left;<a name="line.57"></a>
+<span class="sourceLineNo">058</span>    /**<a name="line.58"></a>
+<span class="sourceLineNo">059</span>     * Second character sequence.<a name="line.59"></a>
+<span class="sourceLineNo">060</span>     */<a name="line.60"></a>
+<span class="sourceLineNo">061</span>    private final String right;<a name="line.61"></a>
+<span class="sourceLineNo">062</span>    /**<a name="line.62"></a>
+<span class="sourceLineNo">063</span>     * Temporary array.<a name="line.63"></a>
+<span class="sourceLineNo">064</span>     */<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    private final int[] vDown;<a name="line.65"></a>
+<span class="sourceLineNo">066</span>    /**<a name="line.66"></a>
+<span class="sourceLineNo">067</span>     * Temporary array.<a name="line.67"></a>
+<span class="sourceLineNo">068</span>     */<a name="line.68"></a>
+<span class="sourceLineNo">069</span>    private final int[] vUp;<a name="line.69"></a>
+<span class="sourceLineNo">070</span><a name="line.70"></a>
+<span class="sourceLineNo">071</span>    /**<a name="line.71"></a>
+<span class="sourceLineNo">072</span>     * Simple constructor.<a name="line.72"></a>
+<span class="sourceLineNo">073</span>     * &lt;p&gt;<a name="line.73"></a>
+<span class="sourceLineNo">074</span>     * Creates a new instance of StringsComparator.<a name="line.74"></a>
+<span class="sourceLineNo">075</span>     * &lt;/p&gt;<a name="line.75"></a>
+<span class="sourceLineNo">076</span>     * &lt;p&gt;<a name="line.76"></a>
+<span class="sourceLineNo">077</span>     * It is &lt;em&gt;guaranteed&lt;/em&gt; that the comparisons will always be done as<a name="line.77"></a>
+<span class="sourceLineNo">078</span>     * &lt;code&gt;o1.equals(o2)&lt;/code&gt; where &lt;code&gt;o1&lt;/code&gt; belongs to the first<a name="line.78"></a>
+<span class="sourceLineNo">079</span>     * sequence and &lt;code&gt;o2&lt;/code&gt; belongs to the second sequence. This can be<a name="line.79"></a>
+<span class="sourceLineNo">080</span>     * important if subclassing is used for some elements in the first sequence<a name="line.80"></a>
+<span class="sourceLineNo">081</span>     * and the &lt;code&gt;equals&lt;/code&gt; method is specialized.<a name="line.81"></a>
+<span class="sourceLineNo">082</span>     * &lt;/p&gt;<a name="line.82"></a>
+<span class="sourceLineNo">083</span>     *<a name="line.83"></a>
+<span class="sourceLineNo">084</span>     * @param left first character sequence to be compared<a name="line.84"></a>
+<span class="sourceLineNo">085</span>     * @param right second character sequence to be compared<a name="line.85"></a>
+<span class="sourceLineNo">086</span>     */<a name="line.86"></a>
+<span class="sourceLineNo">087</span>    public StringsComparator(String left, String right) {<a name="line.87"></a>
+<span class="sourceLineNo">088</span>        this.left = left;<a name="line.88"></a>
+<span class="sourceLineNo">089</span>        this.right = right;<a name="line.89"></a>
+<span class="sourceLineNo">090</span><a name="line.90"></a>
+<span class="sourceLineNo">091</span>        final int size = left.length() + right.length() + 2;<a name="line.91"></a>
+<span class="sourceLineNo">092</span>        vDown = new int[size];<a name="line.92"></a>
+<span class="sourceLineNo">093</span>        vUp   = new int[size];<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    }<a name="line.94"></a>
+<span class="sourceLineNo">095</span><a name="line.95"></a>
+<span class="sourceLineNo">096</span>    /**<a name="line.96"></a>
+<span class="sourceLineNo">097</span>     * Get the {@link EditScript} object.<a name="line.97"></a>
+<span class="sourceLineNo">098</span>     * &lt;p&gt;<a name="line.98"></a>
+<span class="sourceLineNo">099</span>     * It is guaranteed that the objects embedded in the {@link InsertCommand<a name="line.99"></a>
+<span class="sourceLineNo">100</span>     * insert commands} come from the second sequence and that the objects<a name="line.100"></a>
+<span class="sourceLineNo">101</span>     * embedded in either the {@link DeleteCommand delete commands} or<a name="line.101"></a>
+<span class="sourceLineNo">102</span>     * {@link KeepCommand keep commands} come from the first sequence. This can<a name="line.102"></a>
+<span class="sourceLineNo">103</span>     * be important if subclassing is used for some elements in the first<a name="line.103"></a>
+<span class="sourceLineNo">104</span>     * sequence and the &lt;code&gt;equals&lt;/code&gt; method is specialized.<a name="line.104"></a>
+<span class="sourceLineNo">105</span>     * &lt;/p&gt;<a name="line.105"></a>
+<span class="sourceLineNo">106</span>     *<a name="line.106"></a>
+<span class="sourceLineNo">107</span>     * @return the edit script resulting from the comparison of the two<a name="line.107"></a>
+<span class="sourceLineNo">108</span>     *         sequences<a name="line.108"></a>
+<span class="sourceLineNo">109</span>     */<a name="line.109"></a>
+<span class="sourceLineNo">110</span>    public EditScript&lt;Character&gt; getScript() {<a name="line.110"></a>
+<span class="sourceLineNo">111</span>        final EditScript&lt;Character&gt; script = new EditScript&lt;Character&gt;();<a name="line.111"></a>
+<span class="sourceLineNo">112</span>        buildScript(0, left.length(), 0, right.length(), script);<a name="line.112"></a>
+<span class="sourceLineNo">113</span>        return script;<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    }<a name="line.114"></a>
+<span class="sourceLineNo">115</span><a name="line.115"></a>
+<span class="sourceLineNo">116</span>    /**<a name="line.116"></a>
+<span class="sourceLineNo">117</span>     * Build an edit script.<a name="line.117"></a>
+<span class="sourceLineNo">118</span>     *<a name="line.118"></a>
+<span class="sourceLineNo">119</span>     * @param start1  the begin of the first sequence to be compared<a name="line.119"></a>
+<span class="sourceLineNo">120</span>     * @param end1  the end of the first sequence to be compared<a name="line.120"></a>
+<span class="sourceLineNo">121</span>     * @param start2  the begin of the second sequence to be compared<a name="line.121"></a>
+<span class="sourceLineNo">122</span>     * @param end2  the end of the second sequence to be compared<a name="line.122"></a>
+<span class="sourceLineNo">123</span>     * @param script the edited script<a name="line.123"></a>
+<span class="sourceLineNo">124</span>     */<a name="line.124"></a>
+<span class="sourceLineNo">125</span>    private void buildScript(final int start1, final int end1, final int start2, final int end2,<a name="line.125"></a>
+<span class="sourceLineNo">126</span>            final EditScript&lt;Character&gt; script) {<a name="line.126"></a>
+<span class="sourceLineNo">127</span>        final Snake middle = getMiddleSnake(start1, end1, start2, end2);<a name="line.127"></a>
+<span class="sourceLineNo">128</span><a name="line.128"></a>
+<span class="sourceLineNo">129</span>        if (middle == null<a name="line.129"></a>
+<span class="sourceLineNo">130</span>                || middle.getStart() == end1 &amp;&amp; middle.getDiag() == end1 - end2<a name="line.130"></a>
+<span class="sourceLineNo">131</span>                || middle.getEnd() == start1 &amp;&amp; middle.getDiag() == start1 - start2) {<a name="line.131"></a>
+<span class="sourceLineNo">132</span><a name="line.132"></a>
+<span class="sourceLineNo">133</span>            int i = start1;<a name="line.133"></a>
+<span class="sourceLineNo">134</span>            int j = start2;<a name="line.134"></a>
+<span class="sourceLineNo">135</span>            while (i &lt; end1 || j &lt; end2) {<a name="line.135"></a>
+<span class="sourceLineNo">136</span>                if (i &lt; end1 &amp;&amp; j &lt; end2 &amp;&amp; left.charAt(i) == right.charAt(j)) {<a name="line.136"></a>
+<span class="sourceLineNo">137</span>                    script.append(new KeepCommand&lt;Character&gt;(left.charAt(i)));<a name="line.137"></a>
+<span class="sourceLineNo">138</span>                    ++i;<a name="line.138"></a>
+<span class="sourceLineNo">139</span>                    ++j;<a name="line.139"></a>
+<span class="sourceLineNo">140</span>                } else {<a name="line.140"></a>
+<span class="sourceLineNo">141</span>                    if (end1 - start1 &gt; end2 - start2) {<a name="line.141"></a>
+<span class="sourceLineNo">142</span>                        script.append(new DeleteCommand&lt;Character&gt;(left.charAt(i)));<a name="line.142"></a>
+<span class="sourceLineNo">143</span>                        ++i;<a name="line.143"></a>
+<span class="sourceLineNo">144</span>                    } else {<a name="line.144"></a>
+<span class="sourceLineNo">145</span>                        script.append(new InsertCommand&lt;Character&gt;(right.charAt(j)));<a name="line.145"></a>
+<span class="sourceLineNo">146</span>                        ++j;<a name="line.146"></a>
+<span class="sourceLineNo">147</span>                    }<a name="line.147"></a>
+<span class="sourceLineNo">148</span>                }<a name="line.148"></a>
+<span class="sourceLineNo">149</span>            }<a name="line.149"></a>
+<span class="sourceLineNo">150</span><a name="line.150"></a>
+<span class="sourceLineNo">151</span>        } else {<a name="line.151"></a>
 <span class="sourceLineNo">152</span><a name="line.152"></a>
-<span class="sourceLineNo">153</span>        } else {<a name="line.153"></a>
-<span class="sourceLineNo">154</span><a name="line.154"></a>
-<span class="sourceLineNo">155</span>            buildScript(start1, middle.getStart(),<a name="line.155"></a>
-<span class="sourceLineNo">156</span>                        start2, middle.getStart() - middle.getDiag(),<a name="line.156"></a>
-<span class="sourceLineNo">157</span>                        script);<a name="line.157"></a>
-<span class="sourceLineNo">158</span>            for (int i = middle.getStart(); i &lt; middle.getEnd(); ++i) {<a name="line.158"></a>
-<span class="sourceLineNo">159</span>                script.append(new KeepCommand&lt;Character&gt;(left.charAt(i)));<a name="line.159"></a>
-<span class="sourceLineNo">160</span>            }<a name="line.160"></a>
-<span class="sourceLineNo">161</span>            buildScript(middle.getEnd(), end1,<a name="line.161"></a>
-<span class="sourceLineNo">162</span>                        middle.getEnd() - middle.getDiag(), end2,<a name="line.162"></a>
-<span class="sourceLineNo">163</span>                        script);<a name="line.163"></a>
-<span class="sourceLineNo">164</span>        }<a name="line.164"></a>
-<span class="sourceLineNo">165</span>    }<a name="line.165"></a>
-<span class="sourceLineNo">166</span><a name="line.166"></a>
-<span class="sourceLineNo">167</span>    /**<a name="line.167"></a>
-<span class="sourceLineNo">168</span>     * Get the middle snake corresponding to two subsequences of the<a name="line.168"></a>
-<span class="sourceLineNo">169</span>     * main sequences.<a name="line.169"></a>
-<span class="sourceLineNo">170</span>     * &lt;p&gt;<a name="line.170"></a>
-<span class="sourceLineNo">171</span>     * The snake is found using the MYERS Algorithm (this algorithms has<a name="line.171"></a>
-<span class="sourceLineNo">172</span>     * also been implemented in the GNU diff program). This algorithm is<a name="line.172"></a>
-<span class="sourceLineNo">173</span>     * explained in Eugene Myers article:<a name="line.173"></a>
-<span class="sourceLineNo">174</span>     * &lt;a href="http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps"&gt;<a name="line.174"></a>
-<span class="sourceLineNo">175</span>     * An O(ND) Difference Algorithm and Its Variations&lt;/a&gt;.<a name="line.175"></a>
-<span class="sourceLineNo">176</span>     * &lt;/p&gt;<a name="line.176"></a>
-<span class="sourceLineNo">177</span>     *<a name="line.177"></a>
-<span class="sourceLineNo">178</span>     * @param start1  the begin of the first sequence to be compared<a name="line.178"></a>
-<span class="sourceLineNo">179</span>     * @param end1  the end of the first sequence to be compared<a name="line.179"></a>
-<span class="sourceLineNo">180</span>     * @param start2  the begin of the second sequence to be compared<a name="line.180"></a>
-<span class="sourceLineNo">181</span>     * @param end2  the end of the second sequence to be compared<a name="line.181"></a>
-<span class="sourceLineNo">182</span>     * @return the middle snake<a name="line.182"></a>
-<span class="sourceLineNo">183</span>     */<a name="line.183"></a>
-<span class="sourceLineNo">184</span>    private Snake getMiddleSnake(int start1, int end1, int start2, int end2) {<a name="line.184"></a>
-<span class="sourceLineNo">185</span>        // Myers Algorithm<a name="line.185"></a>
-<span class="sourceLineNo">186</span>        // Initialisations<a name="line.186"></a>
-<span class="sourceLineNo">187</span>        final int m = end1 - start1;<a name="line.187"></a>
-<span class="sourceLineNo">188</span>        final int n = end2 - start2;<a name="line.188"></a>
-<span class="sourceLineNo">189</span>        if (m == 0 || n == 0) {<a name="line.189"></a>
-<span class="sourceLineNo">190</span>            return null;<a name="line.190"></a>
-<span class="sourceLineNo">191</span>        }<a name="line.191"></a>
-<span class="sourceLineNo">192</span><a name="line.192"></a>
-<span class="sourceLineNo">193</span>        final int delta  = m - n;<a name="line.193"></a>
-<span class="sourceLineNo">194</span>        final int sum    = n + m;<a name="line.194"></a>
-<span class="sourceLineNo">195</span>        final int offset = (sum % 2 == 0 ? sum : sum + 1) / 2;<a name="line.195"></a>
-<span class="sourceLineNo">196</span>        vDown[1 + offset] = start1;<a name="line.196"></a>
-<span class="sourceLineNo">197</span>        vUp[1 + offset]   = end1 + 1;<a name="line.197"></a>
-<span class="sourceLineNo">198</span><a name="line.198"></a>
-<span class="sourceLineNo">199</span>        for (int d = 0; d &lt;= offset; ++d) {<a name="line.199"></a>
-<span class="sourceLineNo">200</span>            // Down<a name="line.200"></a>
-<span class="sourceLineNo">201</span>            for (int k = -d; k &lt;= d; k += 2) {<a name="line.201"></a>
-<span class="sourceLineNo">202</span>                // First step<a name="line.202"></a>
-<span class="sourceLineNo">203</span><a name="line.203"></a>
-<span class="sourceLineNo">204</span>                final int i = k + offset;<a name="line.204"></a>
-<span class="sourceLineNo">205</span>                if (k == -d || k != d &amp;&amp; vDown[i - 1] &lt; vDown[i + 1]) {<a name="line.205"></a>
-<span class="sourceLineNo">206</span>                    vDown[i] = vDown[i + 1];<a name="line.206"></a>
-<span class="sourceLineNo">207</span>                } else {<a name="line.207"></a>
-<span class="sourceLineNo">208</span>                    vDown[i] = vDown[i - 1] + 1;<a name="line.208"></a>
-<span class="sourceLineNo">209</span>                }<a name="line.209"></a>
-<span class="sourceLineNo">210</span><a name="line.210"></a>
-<span class="sourceLineNo">211</span>                int x = vDown[i];<a name="line.211"></a>
-<span class="sourceLineNo">212</span>                int y = x - start1 + start2 - k;<a name="line.212"></a>
-<span class="sourceLineNo">213</span><a name="line.213"></a>
-<span class="sourceLineNo">214</span>                while (x &lt; end1 &amp;&amp; y &lt; end2 &amp;&amp; left.charAt(x) == right.charAt(y)) {<a name="line.214"></a>
-<span class="sourceLineNo">215</span>                    vDown[i] = ++x;<a name="line.215"></a>
-<span class="sourceLineNo">216</span>                    ++y;<a name="line.216"></a>
-<span class="sourceLineNo">217</span>                }<a name="line.217"></a>
-<span class="sourceLineNo">218</span>                // Second step<a name="line.218"></a>
-<span class="sourceLineNo">219</span>                if (delta % 2 != 0 &amp;&amp; delta - d &lt;= k &amp;&amp; k &lt;= delta + d) {<a name="line.219"></a>
-<span class="sourceLineNo">220</span>                    if (vUp[i - delta] &lt;= vDown[i]) {<a name="line.220"></a>
-<span class="sourceLineNo">221</span>                        return buildSnake(vUp[i - delta], k + start1 - start2, end1, end2);<a name="line.221"></a>
-<span class="sourceLineNo">222</span>                    }<a name="line.222"></a>
-<span class="sourceLineNo">223</span>                }<a name="line.223"></a>
-<span class="sourceLineNo">224</span>            }<a name="line.224"></a>
-<span class="sourceLineNo">225</span><a name="line.225"></a>
-<span class="sourceLineNo">226</span>            // Up<a name="line.226"></a>
-<span class="sourceLineNo">227</span>            for (int k = delta - d; k &lt;= delta + d; k += 2) {<a name="line.227"></a>
-<span class="sourceLineNo">228</span>                // First step<a name="line.228"></a>
-<span class="sourceLineNo">229</span>                final int i = k + offset - delta;<a name="line.229"></a>
-<span class="sourceLineNo">230</span>                if (k == delta - d<a name="line.230"></a>
-<span class="sourceLineNo">231</span>                        || k != delta + d &amp;&amp; vUp[i + 1] &lt;= vUp[i - 1]) {<a name="line.231"></a>
-<span class="sourceLineNo">232</span>                    vUp[i] = vUp[i + 1] - 1;<a name="line.232"></a>
-<span class="sourceLineNo">233</span>                } else {<a name="line.233"></a>
-<span class="sourceLineNo">234</span>                    vUp[i] = vUp[i - 1];<a name="line.234"></a>
-<span class="sourceLineNo">235</span>                }<a name="line.235"></a>
-<span class="sourceLineNo">236</span><a name="line.236"></a>
-<span class="sourceLineNo">237</span>                int x = vUp[i] - 1;<a name="line.237"></a>
-<span class="sourceLineNo">238</span>                int y = x - start1 + start2 - k;<a name="line.238"></a>
-<span class="sourceLineNo">239</span>                while (x &gt;= start1 &amp;&amp; y &gt;= start2<a name="line.239"></a>
-<span class="sourceLineNo">240</span>                        &amp;&amp; left.charAt(x) == right.charAt(y)) {<a name="line.240"></a>
-<span class="sourceLineNo">241</span>                    vUp[i] = x--;<a name="line.241"></a>
-<span class="sourceLineNo">242</span>                    y--;<a name="line.242"></a>
-<span class="sourceLineNo">243</span>                }<a name="line.243"></a>
-<span class="sourceLineNo">244</span>                // Second step<a name="line.244"></a>
-<span class="sourceLineNo">245</span>                if (delta % 2 == 0 &amp;&amp; -d &lt;= k &amp;&amp; k &lt;= d) {<a name="line.245"></a>
-<span class="sourceLineNo">246</span>                    if (vUp[i] &lt;= vDown[i + delta]) {<a name="line.246"></a>
-<span class="sourceLineNo">247</span>                        return buildSnake(vUp[i], k + start1 - start2, end1, end2);<a name="line.247"></a>
-<span class="sourceLineNo">248</span>                    }<a name="line.248"></a>
-<span class="sourceLineNo">249</span>                }<a name="line.249"></a>
-<span class="sourceLineNo">250</span>            }<a name="line.250"></a>
-<span class="sourceLineNo">251</span>        }<a name="line.251"></a>
-<span class="sourceLineNo">252</span><a name="line.252"></a>
-<span class="sourceLineNo">253</span>        // this should not happen<a name="line.253"></a>
-<span class="sourceLineNo">254</span>        throw new RuntimeException("Internal Error");<a name="line.254"></a>
-<span class="sourceLineNo">255</span>    }<a name="line.255"></a>
-<span class="sourceLineNo">256</span><a name="line.256"></a>
-<span class="sourceLineNo">257</span>    /**<a name="line.257"></a>
-<span class="sourceLineNo">258</span>     * Build a snake.<a name="line.258"></a>
-<span class="sourceLineNo">259</span>     *<a name="line.259"></a>
-<span class="sourceLineNo">260</span>     * @param start  the value of the start of the snake<a name="line.260"></a>
-<span class="sourceLineNo">261</span>     * @param diag  the value of the diagonal of the snake<a name="line.261"></a>
-<span class="sourceLineNo">262</span>     * @param end1  the value of the end of the first sequence to be compared<a name="line.262"></a>
-<span class="sourceLineNo">263</span>     * @param end2  the value of the end of the second sequence to be compared<a name="line.263"></a>
-<span class="sourceLineNo">264</span>     * @return the snake built<a name="line.264"></a>
-<span class="sourceLineNo">265</span>     */<a name="line.265"></a>
-<span class="sourceLineNo">266</span>    private Snake buildSnake(final int start, final int diag, final int end1, final int end2) {<a name="line.266"></a>
-<span class="sourceLineNo">267</span>        int end = start;<a name="line.267"></a>
-<span class="sourceLineNo">268</span>        while (end - diag &lt; end2<a name="line.268"></a>
-<span class="sourceLineNo">269</span>                &amp;&amp; end &lt; end1<a name="line.269"></a>
-<span class="sourceLineNo">270</span>                &amp;&amp; left.charAt(end) == right.charAt(end - diag)) {<a name="line.270"></a>
-<span class="sourceLineNo">271</span>            ++end;<a name="line.271"></a>
-<span class="sourceLineNo">272</span>        }<a name="line.272"></a>
-<span class="sourceLineNo">273</span>        return new Snake(start, end, diag);<a name="line.273"></a>
-<span class="sourceLineNo">274</span>    }<a name="line.274"></a>
-<span class="sourceLineNo">275</span><a name="line.275"></a>
-<span class="sourceLineNo">276</span>    /**<a name="line.276"></a>
-<span class="sourceLineNo">277</span>     * This class is a simple placeholder to hold the end part of a path<a name="line.277"></a>
-<span class="sourceLineNo">278</span>     * under construction in a {@link StringsComparator StringsComparator}.<a name="line.278"></a>
-<span class="sourceLineNo">279</span>     */<a name="line.279"></a>
-<span class="sourceLineNo">280</span>    private static class Snake {<a name="line.280"></a>
-<span class="sourceLineNo">281</span><a name="line.281"></a>
-<span class="sourceLineNo">282</span>        /** Start index. */<a name="line.282"></a>
-<span class="sourceLineNo">283</span>        private final int start;<a name="line.283"></a>
-<span class="sourceLineNo">284</span><a name="line.284"></a>
-<span class="sourceLineNo">285</span>        /** End index. */<a name="line.285"></a>
-<span class="sourceLineNo">286</span>        private final int end;<a name="line.286"></a>
-<span class="sourceLineNo">287</span><a name="line.287"></a>
-<span class="sourceLineNo">288</span>        /** Diagonal number. */<a name="line.288"></a>
-<span class="sourceLineNo">289</span>        private final int diag;<a name="line.289"></a>
-<span class="sourceLineNo">290</span><a name="line.290"></a>
-<span class="sourceLineNo">291</span>        /**<a name="line.291"></a>
-<span class="sourceLineNo">292</span>         * Simple constructor. Creates a new instance of Snake with specified indices.<a name="line.292"></a>
-<span class="sourceLineNo">293</span>         *<a name="line.293"></a>
-<span class="sourceLineNo">294</span>         * @param start  start index of the snake<a name="line.294"></a>
-<span class="sourceLineNo">295</span>         * @param end  end index of the snake<a name="line.295"></a>
-<span class="sourceLineNo">296</span>         * @param diag  diagonal number<a name="line.296"></a>
-<span class="sourceLineNo">297</span>         */<a name="line.297"></a>
-<span class="sourceLineNo">298</span>        public Snake(final int start, final int end, final int diag) {<a name="line.298"></a>
-<span class="sourceLineNo">299</span>            this.start = start;<a name="line.299"></a>
-<span class="sourceLineNo">300</span>            this.end   = end;<a name="line.300"></a>
-<span class="sourceLineNo">301</span>            this.diag  = diag;<a name="line.301"></a>
-<span class="sourceLineNo">302</span>        }<a name="line.302"></a>
-<span class="sourceLineNo">303</span><a name="line.303"></a>
-<span class="sourceLineNo">304</span>        /**<a name="line.304"></a>
-<span class="sourceLineNo">305</span>         * Get the start index of the snake.<a name="line.305"></a>
-<span class="sourceLineNo">306</span>         *<a name="line.306"></a>
-<span class="sourceLineNo">307</span>         * @return start index of the snake<a name="line.307"></a>
-<span class="sourceLineNo">308</span>         */<a name="line.308"></a>
-<span class="sourceLineNo">309</span>        public int getStart() {<a name="line.309"></a>
-<span class="sourceLineNo">310</span>            return start;<a name="line.310"></a>
-<span class="sourceLineNo">311</span>        }<a name="line.311"></a>
-<span class="sourceLineNo">312</span><a name="line.312"></a>
-<span class="sourceLineNo">313</span>        /**<a name="line.313"></a>
-<span class="sourceLineNo">314</span>         * Get the end index of the snake.<a name="line.314"></a>
-<span class="sourceLineNo">315</span>         *<a name="line.315"></a>
-<span class="sourceLineNo">316</span>         * @return end index of the snake<a name="line.316"></a>
-<span class="sourceLineNo">317</span>         */<a name="line.317"></a>
-<span class="sourceLineNo">318</span>        public int getEnd() {<a name="line.318"></a>
-<span class="sourceLineNo">319</span>            return end;<a name="line.319"></a>
-<span class="sourceLineNo">320</span>        }<a name="line.320"></a>
-<span class="sourceLineNo">321</span><a name="line.321"></a>
-<span class="sourceLineNo">322</span>        /**<a name="line.322"></a>
-<span class="sourceLineNo">323</span>         * Get the diagonal number of the snake.<a name="line.323"></a>
-<span class="sourceLineNo">324</span>         *<a name="line.324"></a>
-<span class="sourceLineNo">325</span>         * @return diagonal number of the snake<a name="line.325"></a>
-<span class="sourceLineNo">326</span>         */<a name="line.326"></a>
-<span class="sourceLineNo">327</span>        public int getDiag() {<a name="line.327"></a>
-<span class="sourceLineNo">328</span>            return diag;<a name="line.328"></a>
-<span class="sourceLineNo">329</span>        }<a name="line.329"></a>
-<span class="sourceLineNo">330</span>    }<a name="line.330"></a>
-<span class="sourceLineNo">331</span><a name="line.331"></a>
-<span class="sourceLineNo">332</span>}<a name="line.332"></a>
+<span class="sourceLineNo">153</span>            buildScript(start1, middle.getStart(),<a name="line.153"></a>
+<span class="sourceLineNo">154</span>                        start2, middle.getStart() - middle.getDiag(),<a name="line.154"></a>
+<span class="sourceLineNo">155</span>                        script);<a name="line.155"></a>
+<span class="sourceLineNo">156</span>            for (int i = middle.getStart(); i &lt; middle.getEnd(); ++i) {<a name="line.156"></a>
+<span class="sourceLineNo">157</span>                script.append(new KeepCommand&lt;Character&gt;(left.charAt(i)));<a name="line.157"></a>
+<span class="sourceLineNo">158</span>            }<a name="line.158"></a>
+<span class="sourceLineNo">159</span>            buildScript(middle.getEnd(), end1,<a name="line.159"></a>
+<span class="sourceLineNo">160</span>                        middle.getEnd() - middle.getDiag(), end2,<a name="line.160"></a>
+<span class="sourceLineNo">161</span>                        script);<a name="line.161"></a>
+<span class="sourceLineNo">162</span>        }<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    }<a name="line.163"></a>
+<span class="sourceLineNo">164</span><a name="line.164"></a>
+<span class="sourceLineNo">165</span>    /**<a name="line.165"></a>
+<span class="sourceLineNo">166</span>     * Get the middle snake corresponding to two subsequences of the<a name="line.166"></a>
+<span class="sourceLineNo">167</span>     * main sequences.<a name="line.167"></a>
+<span class="sourceLineNo">168</span>     * &lt;p&gt;<a name="line.168"></a>
+<span class="sourceLineNo">169</span>     * The snake is found using the MYERS Algorithm (this algorithms has<a name="line.169"></a>
+<span class="sourceLineNo">170</span>     * also been implemented in the GNU diff program). This algorithm is<a name="line.170"></a>
+<span class="sourceLineNo">171</span>     * explained in Eugene Myers article:<a name="line.171"></a>
+<span class="sourceLineNo">172</span>     * &lt;a href="http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps"&gt;<a name="line.172"></a>
+<span class="sourceLineNo">173</span>     * An O(ND) Difference Algorithm and Its Variations&lt;/a&gt;.<a name="line.173"></a>
+<span class="sourceLineNo">174</span>     * &lt;/p&gt;<a name="line.174"></a>
+<span class="sourceLineNo">175</span>     *<a name="line.175"></a>
+<span class="sourceLineNo">176</span>     * @param start1  the begin of the first sequence to be compared<a name="line.176"></a>
+<span class="sourceLineNo">177</span>     * @param end1  the end of the first sequence to be compared<a name="line.177"></a>
+<span class="sourceLineNo">178</span>     * @param start2  the begin of the second sequence to be compared<a name="line.178"></a>
+<span class="sourceLineNo">179</span>     * @param end2  the end of the second sequence to be compared<a name="line.179"></a>
+<span class="sourceLineNo">180</span>     * @return the middle snake<a name="line.180"></a>
+<span class="sourceLineNo">181</span>     */<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    private Snake getMiddleSnake(int start1, int end1, int start2, int end2) {<a name="line.182"></a>
+<span class="sourceLineNo">183</span>        // Myers Algorithm<a name="line.183"></a>
+<span class="sourceLineNo">184</span>        // Initialisations<a name="line.184"></a>
+<span class="sourceLineNo">185</span>        final int m = end1 - start1;<a name="line.185"></a>
+<span class="sourceLineNo">186</span>        final int n = end2 - start2;<a name="line.186"></a>
+<span class="sourceLineNo">187</span>        if (m == 0 || n == 0) {<a name="line.187"></a>
+<span class="sourceLineNo">188</span>            return null;<a name="line.188"></a>
+<span class="sourceLineNo">189</span>        }<a name="line.189"></a>
+<span class="sourceLineNo">190</span><a name="line.190"></a>
+<span class="sourceLineNo">191</span>        final int delta  = m - n;<a name="line.191"></a>
+<span class="sourceLineNo">192</span>        final int sum    = n + m;<a name="line.192"></a>
+<span class="sourceLineNo">193</span>        final int offset = (sum % 2 == 0 ? sum : sum + 1) / 2;<a name="line.193"></a>
+<span class="sourceLineNo">194</span>        vDown[1 + offset] = start1;<a name="line.194"></a>
+<span class="sourceLineNo">195</span>        vUp[1 + offset]   = end1 + 1;<a name="line.195"></a>
+<span class="sourceLineNo">196</span><a name="line.196"></a>
+<span class="sourceLineNo">197</span>        for (int d = 0; d &lt;= offset; ++d) {<a name="line.197"></a>
+<span class="sourceLineNo">198</span>            // Down<a name="line.198"></a>
+<span class="sourceLineNo">199</span>            for (int k = -d; k &lt;= d; k += 2) {<a name="line.199"></a>
+<span class="sourceLineNo">200</span>                // First step<a name="line.200"></a>
+<span class="sourceLineNo">201</span><a name="line.201"></a>
+<span class="sourceLineNo">202</span>                final int i = k + offset;<a name="line.202"></a>
+<span class="sourceLineNo">203</span>                if (k == -d || k != d &amp;&amp; vDown[i - 1] &lt; vDown[i + 1]) {<a name="line.203"></a>
+<span class="sourceLineNo">204</span>                    vDown[i] = vDown[i + 1];<a name="line.204"></a>
+<span class="sourceLineNo">205</span>                } else {<a name="line.205"></a>
+<span class="sourceLineNo">206</span>                    vDown[i] = vDown[i - 1] + 1;<a name="line.206"></a>
+<span class="sourceLineNo">207</span>                }<a name="line.207"></a>
+<span class="sourceLineNo">208</span><a name="line.208"></a>
+<span class="sourceLineNo">209</span>                int x = vDown[i];<a name="line.209"></a>
+<span class="sourceLineNo">210</span>                int y = x - start1 + start2 - k;<a name="line.210"></a>
+<span class="sourceLineNo">211</span><a name="line.211"></a>
+<span class="sourceLineNo">212</span>                while (x &lt; end1 &amp;&amp; y &lt; end2 &amp;&amp; left.charAt(x) == right.charAt(y)) {<a name="line.212"></a>
+<span class="sourceLineNo">213</span>                    vDown[i] = ++x;<a name="line.213"></a>
+<span class="sourceLineNo">214</span>                    ++y;<a name="line.214"></a>
+<span class="sourceLineNo">215</span>                }<a name="line.215"></a>
+<span class="sourceLineNo">216</span>                // Second step<a name="line.216"></a>
+<span class="sourceLineNo">217</span>                if (delta % 2 != 0 &amp;&amp; delta - d &lt;= k &amp;&amp; k &lt;= delta + d) {<a name="line.217"></a>
+<span class="sourceLineNo">218</span>                    if (vUp[i - delta] &lt;= vDown[i]) {<a name="line.218"></a>
+<span class="sourceLineNo">219</span>                        return buildSnake(vUp[i - delta], k + start1 - start2, end1, end2);<a name="line.219"></a>
+<span class="sourceLineNo">220</span>                    }<a name="line.220"></a>
+<span class="sourceLineNo">221</span>                }<a name="line.221"></a>
+<span class="sourceLineNo">222</span>            }<a name="line.222"></a>
+<span class="sourceLineNo">223</span><a name="line.223"></a>
+<span class="sourceLineNo">224</span>            // Up<a name="line.224"></a>
+<span class="sourceLineNo">225</span>            for (int k = delta - d; k &lt;= delta + d; k += 2) {<a name="line.225"></a>
+<span class="sourceLineNo">226</span>                // First step<a name="line.226"></a>
+<span class="sourceLineNo">227</span>                final int i = k + offset - delta;<a name="line.227"></a>
+<span class="sourceLineNo">228</span>                if (k == delta - d<a name="line.228"></a>
+<span class="sourceLineNo">229</span>                        || k != delta + d &amp;&amp; vUp[i + 1] &lt;= vUp[i - 1]) {<a name="line.229"></a>
+<span class="sourceLineNo">230</span>                    vUp[i] = vUp[i + 1] - 1;<a name="line.230"></a>
+<span class="sourceLineNo">231</span>                } else {<a name="line.231"></a>
+<span class="sourceLineNo">232</span>                    vUp[i] = vUp[i - 1];<a name="line.232"></a>
+<span class="sourceLineNo">233</span>                }<a name="line.233"></a>
+<span class="sourceLineNo">234</span><a name="line.234"></a>
+<span class="sourceLineNo">235</span>                int x = vUp[i] - 1;<a name="line.235"></a>
+<span class="sourceLineNo">236</span>                int y = x - start1 + start2 - k;<a name="line.236"></a>
+<span class="sourceLineNo">237</span>                while (x &gt;= start1 &amp;&amp; y &gt;= start2<a name="line.237"></a>
+<span class="sourceLineNo">238</span>                        &amp;&amp; left.charAt(x) == right.charAt(y)) {<a name="line.238"></a>
+<span class="sourceLineNo">239</span>                    vUp[i] = x--;<a name="line.239"></a>
+<span class="sourceLineNo">240</span>                    y--;<a name="line.240"></a>
+<span class="sourceLineNo">241</span>                }<a name="line.241"></a>
+<span class="sourceLineNo">242</span>                // Second step<a name="line.242"></a>
+<span class="sourceLineNo">243</span>                if (delta % 2 == 0 &amp;&amp; -d &lt;= k &amp;&amp; k &lt;= d) {<a name="line.243"></a>
+<span class="sourceLineNo">244</span>                    if (vUp[i] &lt;= vDown[i + delta]) {<a name="line.244"></a>
+<span class="sourceLineNo">245</span>                        return buildSnake(vUp[i], k + start1 - start2, end1, end2);<a name="line.245"></a>
+<span class="sourceLineNo">246</span>                    }<a name="line.246"></a>
+<span class="sourceLineNo">247</span>                }<a name="line.247"></a>
+<span class="sourceLineNo">248</span>            }<a name="line.248"></a>
+<span class="sourceLineNo">249</span>        }<a name="line.249"></a>
+<span class="sourceLineNo">250</span><a name="line.250"></a>
+<span class="sourceLineNo">251</span>        // this should not happen<a name="line.251"></a>
+<span class="sourceLineNo">252</span>        throw new RuntimeException("Internal Error");<a name="line.252"></a>
+<span class="sourceLineNo">253</span>    }<a name="line.253"></a>
+<span class="sourceLineNo">254</span><a name="line.254"></a>
+<span class="sourceLineNo">255</span>    /**<a name="line.255"></a>
+<span class="sourceLineNo">256</span>     * Build a snake.<a name="line.256"></a>
+<span class="sourceLineNo">257</span>     *<a name="line.257"></a>
+<span class="sourceLineNo">258</span>     * @param start  the value of the start of the snake<a name="line.258"></a>
+<span class="sourceLineNo">259</span>     * @param diag  the value of the diagonal of the snake<a name="line.259"></a>
+<span class="sourceLineNo">260</span>     * @param end1  the value of the end of the first sequence to be compared<a name="line.260"></a>
+<span class="sourceLineNo">261</span>     * @param end2  the value of the end of the second sequence to be compared<a name="line.261"></a>
+<span class="sourceLineNo">262</span>     * @return the snake built<a name="line.262"></a>
+<span class="sourceLineNo">263</span>     */<a name="line.263"></a>
+<span class="sourceLineNo">264</span>    private Snake buildSnake(final int start, final int diag, final int end1, final int end2) {<a name="line.264"></a>
+<span class="sourceLineNo">265</span>        int end = start;<a name="line.265"></a>
+<span class="sourceLineNo">266</span>        while (end - diag &lt; end2<a name="line.266"></a>
+<span class="sourceLineNo">267</span>                &amp;&amp; end &lt; end1<a name="line.267"></a>
+<span class="sourceLineNo">268</span>                &amp;&amp; left.charAt(end) == right.charAt(end - diag)) {<a name="line.268"></a>
+<span class="sourceLineNo">269</span>            ++end;<a name="line.269"></a>
+<span class="sourceLineNo">270</span>        }<a name="line.270"></a>
+<span class="sourceLineNo">271</span>        return new Snake(start, end, diag);<a name="line.271"></a>
+<span class="sourceLineNo">272</span>    }<a name="line.272"></a>
+<span class="sourceLineNo">273</span><a name="line.273"></a>
+<span class="sourceLineNo">274</span>    /**<a name="line.274"></a>
+<span class="sourceLineNo">275</span>     * This class is a simple placeholder to hold the end part of a path<a name="line.275"></a>
+<span class="sourceLineNo">276</span>     * under construction in a {@link StringsComparator StringsComparator}.<a name="line.276"></a>
+<span class="sourceLineNo">277</span>     */<a name="line.277"></a>
+<span class="sourceLineNo">278</span>    private static class Snake {<a name="line.278"></a>
+<span class="sourceLineNo">279</span><a name="line.279"></a>
+<span class="sourceLineNo">280</span>        /** Start index. */<a name="line.280"></a>
+<span class="sourceLineNo">281</span>        private final int start;<a name="line.281"></a>
+<span class="sourceLineNo">282</span><a name="line.282"></a>
+<span class="sourceLineNo">283</span>        /** End index. */<a name="line.283"></a>
+<span class="sourceLineNo">284</span>        private final int end;<a name="line.284"></a>
+<span class="sourceLineNo">285</span><a name="line.285"></a>
+<span class="sourceLineNo">286</span>        /** Diagonal number. */<a name="line.286"></a>
+<span class="sourceLineNo">287</span>        private final int diag;<a name="line.287"></a>
+<span class="sourceLineNo">288</span><a name="line.288"></a>
+<span class="sourceLineNo">289</span>        /**<a name="line.289"></a>
+<span class="sourceLineNo">290</span>         * Simple constructor. Creates a new instance of Snake with specified indices.<a name="line.290"></a>
+<span class="sourceLineNo">291</span>         *<a name="line.291"></a>
+<span class="sourceLineNo">292</span>         * @param start  start index of the snake<a name="line.292"></a>
+<span class="sourceLineNo">293</span>         * @param end  end index of the snake<a name="line.293"></a>
+<span class="sourceLineNo">294</span>         * @param diag  diagonal number<a name="line.294"></a>
+<span class="sourceLineNo">295</span>         */<a name="line.295"></a>
+<span class="sourceLineNo">296</span>        public Snake(final int start, final int end, final int diag) {<a name="line.296"></a>
+<span class="sourceLineNo">297</span>            this.start = start;<a name="line.297"></a>
+<span class="sourceLineNo">298</span>            this.end   = end;<a name="line.298"></a>
+<span class="sourceLineNo">299</span>            this.diag  = diag;<a name="line.299"></a>
+<span class="sourceLineNo">300</span>        }<a name="line.300"></a>
+<span class="sourceLineNo">301</span><a name="line.301"></a>
+<span class="sourceLineNo">302</span>        /**<a name="line.302"></a>
+<span class="sourceLineNo">303</span>         * Get the start index of the snake.<a name="line.303"></a>
+<span class="sourceLineNo">304</span>         *<a name="line.304"></a>
+<span class="sourceLineNo">305</span>         * @return start index of the snake<a name="line.305"></a>
+<span class="sourceLineNo">306</span>         */<a name="line.306"></a>
+<span class="sourceLineNo">307</span>        public int getStart() {<a name="line.307"></a>
+<span class="sourceLineNo">308</span>            return start;<a name="line.308"></a>
+<span class="sourceLineNo">309</span>        }<a name="line.309"></a>
+<span class="sourceLineNo">310</span><a name="line.310"></a>
+<span class="sourceLineNo">311</span>        /**<a name="line.311"></a>
+<span class="sourceLineNo">312</span>         * Get the end index of the snake.<a name="line.312"></a>
+<span class="sourceLineNo">313</span>         *<a name="line.313"></a>
+<span class="sourceLineNo">314</span>         * @return end index of the snake<a name="line.314"></a>
+<span class="sourceLineNo">315</span>         */<a name="line.315"></a>
+<span class="sourceLineNo">316</span>        public int getEnd() {<a name="line.316"></a>
+<span class="sourceLineNo">317</span>            return end;<a name="line.317"></a>
+<span class="sourceLineNo">318</span>        }<a name="line.318"></a>
+<span class="sourceLineNo">319</span><a name="line.319"></a>
+<span class="sourceLineNo">320</span>        /**<a name="line.320"></a>
+<span class="sourceLineNo">321</span>         * Get the diagonal number of the snake.<a name="line.321"></a>
+<span class="sourceLineNo">322</span>         *<a name="line.322"></a>
+<span class="sourceLineNo">323</span>         * @return diagonal number of the snake<a name="line.323"></a>
+<span class="sourceLineNo">324</span>         */<a name="line.324"></a>
+<span class="sourceLineNo">325</span>        public int getDiag() {<a name="line.325"></a>
+<span class="sourceLineNo">326</span>            return diag;<a name="line.326"></a>
+<span class="sourceLineNo">327</span>        }<a name="line.327"></a>
+<span class="sourceLineNo">328</span>    }<a name="line.328"></a>
+<span class="sourceLineNo">329</span><a name="line.329"></a>
+<span class="sourceLineNo">330</span>}<a name="line.330"></a>
 
 
 
@@ -401,4 +399,4 @@
 </pre>
 </div>
 </body>
-</html>
+</html>
\ No newline at end of file



Mime
View raw message