From: Michael T H. <mic...@us...> - 2002-11-21 19:54:18
|
Update of /cvsroot/jmol/Jmol/src/org/openscience/jmol In directory sc8-pr-cvs1:/tmp/cvs-serv23049 Modified Files: SortedTableModel.java Removed Files: HeapSorter.java Log Message: converted from HeapSorter to standard Arrays.sort Index: SortedTableModel.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/openscience/jmol/SortedTableModel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** SortedTableModel.java 8 Nov 2002 15:12:11 -0000 1.6 --- SortedTableModel.java 21 Nov 2002 19:54:15 -0000 1.7 *************** *** 32,35 **** --- 32,37 ---- import java.util.ArrayList; import java.util.List; + import java.util.Arrays; + import java.util.Comparator; /** *************** *** 44,49 **** List sortingColumns = new ArrayList(); boolean ascending = true; - CompareRows comparator = new CompareRows(); - HeapSorter sorter = new HeapSorter(comparator); public SortedTableModel(TableModel model) { --- 46,49 ---- *************** *** 52,91 **** } - class CompareRows implements HeapSorter.Comparator { - - public int compare(Object r1, Object r2) { - - int row1 = ((Integer) r1).intValue(); - int row2 = ((Integer) r2).intValue(); - int result = 0; - int level = 0; - while ((result == 0) && (level < sortingColumns.size())) { - int column = ((Integer) sortingColumns.get(level)).intValue(); - Object o1 = model.getValueAt(row1, column); - Object o2 = model.getValueAt(row2, column); - if ((o1 == null) && (o2 == null)) { - - // Null objects are equal. - return 0; - } else if (o1 == null) { - - // Null is less than anything. - return -1; - } else if (o2 == null) { - - // Anything is greather than null. - return 1; - } - - result = ((Comparable) o1).compareTo(o2); - ++level; - } - if (!ascending) { - result = -result; - } - return result; - } - } - public void initializeIndexes() { --- 52,55 ---- *************** *** 103,109 **** void sort() { ! sorter.sort(indexes); ! } /** --- 67,106 ---- void sort() { ! System.out.println("We are sorting!"); ! Arrays.sort(indexes, ! new Comparator() { ! ! public int compare(Object r1, Object r2) { ! ! int row1 = ((Integer) r1).intValue(); ! int row2 = ((Integer) r2).intValue(); ! int result = 0; ! int level = 0; ! while ((result == 0) && (level < sortingColumns.size())) { ! int column = ! ((Integer) sortingColumns.get(level)).intValue(); ! Object o1 = model.getValueAt(row1, column); ! Object o2 = model.getValueAt(row2, column); ! if ((o1 == null) && (o2 == null)) { ! // Null objects are equal. ! return 0; ! } else if (o1 == null) { ! // Null is less than anything. ! return -1; ! } else if (o2 == null) { ! // Anything is greather than null. ! return 1; ! } ! result = ((Comparable) o1).compareTo(o2); ! ++level; ! } ! if (!ascending) { ! result = -result; ! } ! return result; ! } ! }); } + /** --- HeapSorter.java DELETED --- |