File: GenericSorting.html

package info (click to toggle)
libcolt-free-java 1.2.0%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 20,816 kB
  • sloc: java: 30,344; xml: 896; makefile: 24; sh: 3
file content (424 lines) | stat: -rw-r--r-- 21,832 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_05) on Thu Sep 09 20:36:07 PDT 2004 -->
<TITLE>
GenericSorting (Colt 1.2.0 - API Specification)
</TITLE>

<META NAME="keywords" CONTENT="cern.colt.GenericSorting class">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    parent.document.title="GenericSorting (Colt 1.2.0 - API Specification)";
}
</SCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/GenericSorting.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Colt 1.2.0</b></EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../cern/colt/GenericPermuting.html" title="class in cern.colt"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../cern/colt/Partitioning.html" title="class in cern.colt"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="GenericSorting.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>

</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
cern.colt</FONT>
<BR>
Class GenericSorting</H2>
<PRE>
<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A>
  <IMG SRC="../../resources/inherit.gif" ALT="extended by"><B>cern.colt.GenericSorting</B>
</PRE>
<HR>
<DL>
<DT>public class <B>GenericSorting</B><DT>extends <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></DL>

<P>
Generically sorts arbitrary shaped data (for example multiple arrays, 1,2 or 3-d matrices, and so on) using a 
quicksort or mergesort. This class addresses two problems, namely 
<ul>
  <li><i>Sorting multiple arrays in sync</i> 
  <li><i>Sorting by multiple sorting criteria</i> (primary, secondary, tertiary, 
        ...) 
</ul>
<h4>Sorting multiple arrays in sync</h4>
<p>
Assume we have three arrays X, Y and Z. We want to sort all three arrays by 
  X (or some arbitrary comparison function). For example, we have<br>
  <tt>X=[3, 2, 1], Y=[3.0, 2.0, 1.0], Z=[6.0, 7.0, 8.0]</tt>. The output should 
  be <tt><br>
  X=[1, 2, 3], Y=[1.0, 2.0, 3.0], Z=[8.0, 7.0, 6.0]</tt>. </p>
<p>How can we achive this? Here are several alternatives. We could ... </p>
<ol>
  <li> make a list of Point3D objects, sort the list as desired using a comparison 
        function, then copy the results back into X, Y and Z. The classic object-oriented 
        way. </li>
  <li>make an index list [0,1,2,...,N-1], sort the index list using a comparison function, 
        then reorder the elements of X,Y,Z as defined by the index list. Reordering 
        cannot be done in-place, so we need to copy X to some temporary array, then 
        copy in the right order back from the temporary into X. Same for Y and Z. 
  </li>
  <li> use a generic quicksort or mergesort which, whenever two elements in X are swapped, 
        also swaps the corresponding elements in Y and Z. </li>
</ol>
Alternatives 1 and 2 involve quite a lot of copying and allocate significant amounts 
of temporary memory. Alternative 3 involves more swapping, more polymorphic message dispatches, no copying and does not need any temporary memory. 
<p> This class implements alternative 3. It operates on arbitrary shaped data. 
  In fact, it has no idea what kind of data it is sorting. Comparisons and swapping 
  are delegated to user provided objects which know their data and can do the 
  job. 
<p> Lets call the generic data <tt>g</tt> (it may be one array, three linked lists 
  or whatever). This class takes a user comparison function operating on two indexes 
  <tt>(a,b)</tt>, namely an <A HREF="../../cern/colt/function/IntComparator.html" title="interface in cern.colt.function"><CODE>IntComparator</CODE></A>. The comparison function determines 
  whether <tt>g[a]</tt> is equal, less or greater than <tt>g[b]</tt>. The sort, 
  depending on its implementation, can decide to swap the data at index <tt>a</tt> 
  with the data at index <tt>b</tt>. It calls a user provided <A HREF="../../cern/colt/Swapper.html" title="interface in cern.colt"><CODE>Swapper</CODE></A> 
  object that knows how to swap the data of these indexes. 
<p>The following snippet shows how to solve the problem. 
<table>
<td class="PRE"> 
<pre>
final int[] x;
final double[] y;
final double[] z;

x = new int[]    {3,   2,   1  };
y = new double[] {3.0, 2.0, 1.0};
z = new double[] {6.0, 7.0, 8.0};


// this one knows how to swap two indexes (a,b)
Swapper swapper = new Swapper() {
&nbsp;&nbsp;&nbsp;public void swap(int a, int b) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int t1;	double t2, t3;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t1 = x[a]; x[a] = x[b];	x[b] = t1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t2 = y[a]; y[a] = y[b]; y[b] = t2;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t3 = z[a]; z[a] = z[b];	z[b] = t3;
&nbsp;&nbsp;&nbsp;}
};
// simple comparison: compare by X and ignore Y,Z<br>
IntComparator comp = new IntComparator() {
&nbsp;&nbsp;&nbsp;public int compare(int a, int b) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return x[a]==x[b] ? 0 : (x[a]&lt;x[b] ? -1 : 1);
&nbsp;&nbsp;&nbsp;}
};

System.out.println("before:");
System.out.println("X="+Arrays.toString(x));
System.out.println("Y="+Arrays.toString(y));
System.out.println("Z="+Arrays.toString(z));

GenericSorting.quickSort(0, X.length, comp, swapper);
// GenericSorting.mergeSort(0, X.length, comp, swapper);

System.out.println("after:");
System.out.println("X="+Arrays.toString(x));
System.out.println("Y="+Arrays.toString(y));
System.out.println("Z="+Arrays.toString(z));
</pre>
</td>
</table>
<h4>Sorting by multiple sorting criterias (primary, secondary, tertiary, ...)</h4>
<p>Assume again we have three arrays X, Y and Z. Now we want to sort all three 
  arrays, primarily by Y, secondarily by Z (if Y elements are equal). For example, 
  we have<br>
  <tt>X=[6, 7, 8, 9], Y=[3.0, 2.0, 1.0, 3.0], Z=[5.0, 4.0, 4.0, 1.0]</tt>. The 
  output should be <tt><br>
  X=[8, 7, 9, 6], Y=[1.0, 2.0, 3.0, 3.0], Z=[4.0, 4.0, 1.0, 5.0]</tt>. </p>
<p>Here is how to solve the problem. All code in the above example stays the same, 
  except that we modify the comparison function as follows</p>
<table>
<td class="PRE"> 
<pre>
//compare by Y, if that doesn't help, reside to Z
IntComparator comp = new IntComparator() {
&nbsp;&nbsp;&nbsp;public int compare(int a, int b) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (y[a]==y[b]) return z[a]==z[b] ? 0 : (z[a]&lt;z[b] ? -1 : 1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return y[a]&lt;y[b] ? -1 : 1;
&nbsp;&nbsp;&nbsp;}
};
</pre>
</td>
</table>

<h4>Notes</h4>
<p></p>
<p> Sorts involving floating point data and not involving comparators, like, for 
  example provided in the JDK <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/util/Arrays.html" title="class or interface in java.util"><CODE>Arrays</CODE></A> and in the Colt <A HREF="../../cern/colt/Sorting.html" title="class in cern.colt"><CODE>Sorting</CODE></A> handle floating point numbers in special ways to guarantee 
  that NaN's are swapped to the end and -0.0 comes before 0.0. Methods delegating 
  to comparators cannot do this. They rely on the comparator. Thus, if such boundary 
  cases are an issue for the application at hand, comparators explicitly need 
  to implement -0.0 and NaN aware comparisons. Remember: <tt>-0.0 < 0.0 == false</tt>, 
  <tt>(-0.0 == 0.0) == true</tt>, as well as <tt>5.0 &lt; Double.NaN == false</tt>, 
  <tt>5.0 &gt; Double.NaN == false</tt>. Same for <tt>float</tt>.
<h4>Implementation </h4>
<p>The quicksort is a derivative of the JDK 1.2 V1.26 algorithms (which are, in 
  turn, based on Bentley's and McIlroy's fine work).
  The mergesort is a derivative of the JAL algorithms, with optimisations taken from the JDK algorithms.
Both quick and merge sort are "in-place", i.e. do not allocate temporary memory (helper arrays).
Mergesort is <i>stable</i> (by definition), while quicksort is not.
A stable sort is, for example, helpful, if matrices are sorted successively 
by multiple columns. It preserves the relative position of equal elements.
<P>

<P>
<DL>
<DT><B>Version:</B></DT>
  <DD>1.0, 03-Jul-99</DD>
<DT><B>See Also:</B><DD><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/util/Arrays.html" title="class or interface in java.util"><CODE>Arrays</CODE></A>, 
<A HREF="../../cern/colt/Sorting.html" title="class in cern.colt"><CODE>Sorting</CODE></A>, 
<A HREF="../../cern/colt/matrix/doublealgo/Sorting.html" title="class in cern.colt.matrix.doublealgo"><CODE>Sorting</CODE></A></DL>
<HR>

<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->


<!-- =========== FIELD SUMMARY =========== -->


<!-- ======== CONSTRUCTOR SUMMARY ======== -->


<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../cern/colt/GenericSorting.html#mergeSort(int, int, cern.colt.function.IntComparator, cern.colt.Swapper)">mergeSort</A></B>(int&nbsp;fromIndex,
          int&nbsp;toIndex,
          <A HREF="../../cern/colt/function/IntComparator.html" title="interface in cern.colt.function">IntComparator</A>&nbsp;c,
          <A HREF="../../cern/colt/Swapper.html" title="interface in cern.colt">Swapper</A>&nbsp;swapper)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sorts the specified range of elements according
 to the order induced by the specified comparator.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../cern/colt/GenericSorting.html#quickSort(int, int, cern.colt.function.IntComparator, cern.colt.Swapper)">quickSort</A></B>(int&nbsp;fromIndex,
          int&nbsp;toIndex,
          <A HREF="../../cern/colt/function/IntComparator.html" title="interface in cern.colt.function">IntComparator</A>&nbsp;c,
          <A HREF="../../cern/colt/Swapper.html" title="interface in cern.colt">Swapper</A>&nbsp;swapper)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sorts the specified range of elements according
 to the order induced by the specified comparator.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TD><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A></B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ============ FIELD DETAIL =========== -->


<!-- ========= CONSTRUCTOR DETAIL ======== -->


<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="mergeSort(int, int, cern.colt.function.IntComparator, cern.colt.Swapper)"><!-- --></A><H3>
mergeSort</H3>
<PRE>
public static void <B>mergeSort</B>(int&nbsp;fromIndex,
                             int&nbsp;toIndex,
                             <A HREF="../../cern/colt/function/IntComparator.html" title="interface in cern.colt.function">IntComparator</A>&nbsp;c,
                             <A HREF="../../cern/colt/Swapper.html" title="interface in cern.colt">Swapper</A>&nbsp;swapper)</PRE>
<DL>
<DD>Sorts the specified range of elements according
 to the order induced by the specified comparator.  All elements in the
 range must be <i>mutually comparable</i> by the specified comparator
 (that is, <tt>c.compare(a, b)</tt> must not throw an
 exception for any indexes <tt>a</tt> and
 <tt>b</tt> in the range).<p>

 This sort is guaranteed to be <i>stable</i>:  equal elements will
 not be reordered as a result of the sort.<p>

 The sorting algorithm is a modified mergesort (in which the merge is
 omitted if the highest element in the low sublist is less than the
 lowest element in the high sublist).  This algorithm offers guaranteed
 n*log(n) performance, and can approach linear performance on nearly
 sorted lists.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fromIndex</CODE> - the index of the first element (inclusive) to be sorted.<DD><CODE>toIndex</CODE> - the index of the last element (exclusive) to be sorted.<DD><CODE>c</CODE> - the comparator to determine the order of the generic data.<DD><CODE>swapper</CODE> - an object that knows how to swap the elements at any two indexes (a,b).<DT><B>See Also:</B><DD><A HREF="../../cern/colt/function/IntComparator.html" title="interface in cern.colt.function"><CODE>IntComparator</CODE></A>, 
<A HREF="../../cern/colt/Swapper.html" title="interface in cern.colt"><CODE>Swapper</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="quickSort(int, int, cern.colt.function.IntComparator, cern.colt.Swapper)"><!-- --></A><H3>
quickSort</H3>
<PRE>
public static void <B>quickSort</B>(int&nbsp;fromIndex,
                             int&nbsp;toIndex,
                             <A HREF="../../cern/colt/function/IntComparator.html" title="interface in cern.colt.function">IntComparator</A>&nbsp;c,
                             <A HREF="../../cern/colt/Swapper.html" title="interface in cern.colt">Swapper</A>&nbsp;swapper)</PRE>
<DL>
<DD>Sorts the specified range of elements according
 to the order induced by the specified comparator.  All elements in the
 range must be <i>mutually comparable</i> by the specified comparator
 (that is, <tt>c.compare(a, b)</tt> must not throw an
 exception for any indexes <tt>a</tt> and
 <tt>b</tt> in the range).<p>

 The sorting algorithm is a tuned quicksort,
 adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a
 Sort Function", Software-Practice and Experience, Vol. 23(11)
 P. 1249-1265 (November 1993).  This algorithm offers n*log(n)
 performance on many data sets that cause other quicksorts to degrade to
 quadratic performance.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>fromIndex</CODE> - the index of the first element (inclusive) to be sorted.<DD><CODE>toIndex</CODE> - the index of the last element (exclusive) to be sorted.<DD><CODE>c</CODE> - the comparator to determine the order of the generic data.<DD><CODE>swapper</CODE> - an object that knows how to swap the elements at any two indexes (a,b).<DT><B>See Also:</B><DD><A HREF="../../cern/colt/function/IntComparator.html" title="interface in cern.colt.function"><CODE>IntComparator</CODE></A>, 
<A HREF="../../cern/colt/Swapper.html" title="interface in cern.colt"><CODE>Swapper</CODE></A></DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/GenericSorting.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<b>Colt 1.2.0</b></EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../cern/colt/GenericPermuting.html" title="class in cern.colt"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../cern/colt/Partitioning.html" title="class in cern.colt"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="GenericSorting.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>

</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>
<font size=-1 >Jump to the <a target=_top href=http://dsd.lbl.gov/~hoschek/colt >Colt Homepage</a>
</BODY>
</HTML>