Shell排序

<textarea cols="50" rows="15" name="code" class="java">public class ShellSorter extends Sorter { public void Sort(Object[] list,SortTool tool,boolean descending){ int inc/*增量*/,comp; if(descending) comp = tool.COMP_LESS; else comp = tool.COMP_GRTR; //确定增量 for(inc = 1;inc &lt;= list.length/9;inc = 3*inc+1); for(;inc &gt; 0;inc /= 3){ for(int i=inc;i&lt;list.length;i+=inc){ //对0 0+inc 0+2*inc ...处的元素进行插入排序 Object t = list[i]; int j = i; while((j&gt;=inc)&amp;&amp;(tool.compare(list[j-inc], t)==comp)){ list[j] = list[j-inc]; j -= inc; } list[j] = t; } } } }</textarea>

你可能感兴趣的:(object,list,shell,Class)