Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>public class Mergerer { private int countWay = 0; private int countIndex = 0; private Double[] base; private Double[] sortBase; private Double[] tempBase; private Double[][] arrayWay; private String[] array1; private String[] array2; private String[] array3; private String[] array4; private String[] array5; private String[] array6; List&lt;String[]&gt; listA = new ArrayList&lt;String[]&gt;(); private int countElements = 0; public Double[] getSortBase() { return sortBase; } public Double[] sort() { divide(); merger(base); return sortBase; } public int getCountWay() { return countWay; } public Mergerer(Double[] base, int countWay) { this.countWay = countWay; this.arrayWay = new Double[countWay][base.length + 1]; tempBase = base; countElements = base.length; array1 = new String[base.length * 2]; array2 = new String[base.length * 2]; array3 = new String[base.length * 2]; array4 = new String[base.length * 2]; array5 = new String[base.length * 2]; array6 = new String[base.length * 2]; listA.add(array1); listA.add(array2); listA.add(array3); listA.add(array4); listA.add(array5); listA.add(array6); } public int divide() { int[][] posWay = new int[countWay][1]; int beginIndexPos = 0; int numberWay = 0; int pos = 0; for (int i = 1; i &lt; tempBase.length; i++) { if (tempBase[i] &lt; tempBase[i - 1]) { for (int j = beginIndexPos; j &lt; i; j++) { listA.get(numberWay)[posWay[numberWay][0]] = Double.toString(tempBase[j]); arrayWay[numberWay][posWay[numberWay][0]] = tempBase[j]; posWay[numberWay][0]++; countIndex++; } listA.get(numberWay)[posWay[numberWay][0]] = "'"; posWay[numberWay][0]++; beginIndexPos = i; if (numberWay == countWay - 1) numberWay = 0; else numberWay++; pos = 0; } } for (int i = beginIndexPos; i &lt; tempBase.length; i++) { listA.get(numberWay)[posWay[numberWay][0]] = Double.toString(tempBase[i]); arrayWay[numberWay][posWay[numberWay][0]] = tempBase[i]; posWay[numberWay][0]++; countIndex++; } listA.get(numberWay)[posWay[numberWay][0]] = "'"; return countIndex; } public void printIndex() { for (int i = 0; i &lt; countWay; i++) { for (int j = 0; j &lt; countElements; j++) { if (arrayWay[i][j] != null) System.out.print(arrayWay[i][j]); } System.out.println(); } } public void printIndexList() { for (int i = 0; i &lt; countWay; i++) { for (int j = 0; j &lt; countElements; j++) { if (listA.get(i)[j] != null) System.out.print(listA.get(i)[j]); } System.out.println(); } } public void merger(Double[] base) { List&lt;String[]&gt; listB = new ArrayList&lt;String[]&gt;(); for (int i = 0; i &lt; countWay; i++) { listB.add(new String[base.length * 2]); } int numberWay = 0; int[][] posWay = new int[countWay][1]; double lastAdded = 0; int countSeries = 0; int[] mem = new int[countWay]; for (int i = 0; i &lt; countWay; i++) { mem[i] = 0; } while (true) { double tmp = 999999999; int way = -1; for (int i = 0; i &lt; countWay; i++) { if (listA.get(i)[mem[i]] != null) { String str = listA.get(i)[mem[i]]; if (str.equals("'") &amp;&amp; listA.get(i)[mem[i] + 1] != null) { mem[i]++; str = listA.get(i)[mem[i]]; } if (str != null &amp;&amp; !str.equals("'")) { double step = Double.parseDouble(str); if (tmp &gt;= step) { tmp = Double.parseDouble(str); way = i; } } } } if (lastAdded &gt; tmp || way == -1) { listB.get(numberWay)[posWay[numberWay][0]] = "'"; countSeries++; if (numberWay == countWay - 1) { numberWay = 0; } else numberWay++; } if (way == -1) { break; } mem[way]++; lastAdded = tmp; listB.get(numberWay)[posWay[numberWay][0]] = Double.toString(tmp); posWay[numberWay][0]++; } listA = listB; if (countSeries &gt; 1) { merger(base); } else { sortBase = new Double[countElements]; for (int i = 0; i &lt; countWay; i++) { for (int j = 0; j &lt; countElements; j++) { if (listA.get(i)[j] != null) sortBase[j] = Double.parseDouble(listA.get(i)[j]); } } return; } } </code></pre> <hr> <pre><code> Double[] array = new Double[10]; for (int i=10; i&gt;0; i--) { array[10-i] = i; } Mergerer merg = new Mergerer(array, 4); merg.divide(); merg.merger(array); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload