예제 #1
0
  /**
   * Orders the given array by data type.
   *
   * @param array
   * @param type
   * @param suppressionString
   */
  private void sort(final String[] array, final DataType<?> type, final String suppressionString) {
    GenericSorting.mergeSort(
        0,
        array.length,
        new IntComparator() {

          @Override
          public int compare(int arg0, int arg1) {
            checkInterrupt();
            try {
              String s1 = array[arg0];
              String s2 = array[arg1];
              return (s1 == suppressionString && s2 == suppressionString)
                  ? 0
                  : (s1 == suppressionString
                      ? +1
                      : (s2 == suppressionString ? -1 : type.compare(s1, s2)));
            } catch (IllegalArgumentException | ParseException e) {
              throw new RuntimeException("Some values seem to not conform to the data type", e);
            }
          }
        },
        new Swapper() {
          @Override
          public void swap(int arg0, int arg1) {
            String temp = array[arg0];
            array[arg0] = array[arg1];
            array[arg1] = temp;
          }
        });
  }
예제 #2
0
 /**
  * Orders the given array by the given sort order.
  *
  * @param array
  * @param order
  */
 private void sort(final String[] array, final Map<String, Integer> order) {
   GenericSorting.mergeSort(
       0,
       array.length,
       new IntComparator() {
         @Override
         public int compare(int arg0, int arg1) {
           checkInterrupt();
           Integer order1 = order.get(array[arg0]);
           Integer order2 = order.get(array[arg1]);
           if (order1 == null || order2 == null) {
             throw new RuntimeException("The hierarchy seems to not cover all data values");
           } else {
             return order1.compareTo(order2);
           }
         }
       },
       new Swapper() {
         @Override
         public void swap(int arg0, int arg1) {
           String temp = array[arg0];
           array[arg0] = array[arg1];
           array[arg1] = temp;
         }
       });
 }
예제 #3
0
 public void sortByColumn(int columnIndex) {
   System.out.println("Start sorting table");
   sortColumnIndex = columnIndex;
   GenericSorting.quickSort(0, this.getRowNumber(), compByColumn, swapper);
   System.out.println("Finished sorting table");
 }