equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * |
3 * |
4 * Redistribution and use in source and binary forms, with or without |
4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions |
5 * modification, are permitted provided that the following conditions |
6 * are met: |
6 * are met: |
7 * |
7 * |
69 * @author Philip Milne |
69 * @author Philip Milne |
70 */ |
70 */ |
71 @SuppressWarnings("serial") |
71 @SuppressWarnings("serial") |
72 public final class TableSorter extends TableMap { |
72 public final class TableSorter extends TableMap { |
73 |
73 |
74 int indexes[]; |
74 int[] indexes; |
75 List<Integer> sortingColumns = new ArrayList<Integer>(); |
75 List<Integer> sortingColumns = new ArrayList<Integer>(); |
76 boolean ascending = true; |
76 boolean ascending = true; |
77 int compares; |
77 int compares; |
78 |
78 |
79 public TableSorter() { |
79 public TableSorter() { |
247 // requires twice the space of an in-place algorithm and makes |
247 // requires twice the space of an in-place algorithm and makes |
248 // NlogN assigments shuttling the values between the two |
248 // NlogN assigments shuttling the values between the two |
249 // arrays. The number of compares appears to vary between N-1 and |
249 // arrays. The number of compares appears to vary between N-1 and |
250 // NlogN depending on the initial order but the main reason for |
250 // NlogN depending on the initial order but the main reason for |
251 // using it here is that, unlike qsort, it is stable. |
251 // using it here is that, unlike qsort, it is stable. |
252 public void shuttlesort(int from[], int to[], int low, int high) { |
252 public void shuttlesort(int[] from, int[] to, int low, int high) { |
253 if (high - low < 2) { |
253 if (high - low < 2) { |
254 return; |
254 return; |
255 } |
255 } |
256 int middle = (low + high) / 2; |
256 int middle = (low + high) / 2; |
257 shuttlesort(to, from, low, middle); |
257 shuttlesort(to, from, low, middle); |