package com.hithomelabs.princeton1.module5;

import java.util.Comparator;

public interface MeasurableSort<E> extends ComparatorComparableSort<E> {


    default boolean less(E v, E w, Comparator<E> cmp, SortingMetaData metaData) {
        if (metaData != null)
            metaData.incrementCompares();
        return ComparatorComparableSort.super.less(v, w, cmp);
    }

    default void exch(E[] arr, int j, int i, SortingMetaData metaData) {
        if (metaData != null)
            metaData.incrementExchanges();
        ComparatorComparableSort.super.exch(arr, j, i);
    }

    public void sort(E[] arr, Comparator<E> cmp, SortingMetaData metaData);

}
