package org.algorithmprac.sort;

import com.google.common.base.Stopwatch;

import java.util.concurrent.TimeUnit;

public abstract class AbstractCostAwareSorter extends AbstractSorter implements CostAwareSorter {

    private final Stopwatch stopwatch = Stopwatch.createUnstarted();

    private int cmpCount = 0;

    private int swapCount = 0;

    @Override
    protected void preProcess(Comparable[] a) {
        resetStatistics();
        stopwatch.start();
    }

    private void resetStatistics() {
        stopwatch.reset();
        cmpCount = 0;
        swapCount = 0;
    }

    @Override
    protected void postProcess(Comparable[] a) {
        stopwatch.stop();
    }

    @Override
    public boolean less(Comparable v, Comparable w) {
        ++cmpCount;
        return super.less(v, w);
    }

    @Override
    public void swap(Comparable[] a, int i, int j) {
        ++swapCount;
        super.swap(a, i, j);
    }

    public String getReadableCost() {
        StringBuilder sb = new StringBuilder();
        sb.append("cost is ");
        sb.append(stopwatch.toString());
        sb.append(", compare count is ");
        sb.append(cmpCount);
        sb.append(", swap count is ");
        sb.append(swapCount);
        return sb.toString();
    }

    public long getCost(TimeUnit timeUnit) {
        return stopwatch.elapsed(timeUnit);
    }

    public int getCmpCount() {
        return cmpCount;
    }

    public int getSwapCount() {
        return swapCount;
    }
}

@@ -288,19 +288,20 @@
 private 
-int
+long
  cmpCoun
@@ -320,19 +320,20 @@
 private 
-int
+long
  swapCou
@@ -544,24 +544,25 @@
 cmpCount = 0
+L
 ;%0A        sw
@@ -572,16 +572,17 @@
 ount = 0
+L
 ;%0A    %7D%0A
@@ -1368,27 +1368,28 @@
 %0A    public 
-int
+long
  getCmpCount
@@ -1436,19 +1436,20 @@
  public 
-int
+long
  getSwap

Change comp and swap count from int to long