Class IntegerExchangeCounter

java.lang.Object
it.unimi.dsi.law.big.util.IntegerExchangeCounter

public class IntegerExchangeCounter
extends Object
Computes the number of discordances between two integer score big vectors using Knight's O(n log n) MergeSort-based algorithm.

This class is just a copy of ExchangeCounter using integer big vectors.

See Also:
ExchangeCounter
  • Constructor Details

    • IntegerExchangeCounter

      public IntegerExchangeCounter​(long[][] perm, int[][] v, long[][] support)
      Creates a new exchange counter with a provided support big array.

      This constructor avoids the need to allocate a support big array, in case one is already available.

      Parameters:
      perm - the big array to be sorted.
      v - the score integer big vector used to compare the element of perm.
      support - a big array that will be used as temporary storage during the computation (its content will be erased); must be at least as long as a.
    • IntegerExchangeCounter

      public IntegerExchangeCounter​(long[][] perm, int[][] v)
      Creates a new exchange counter.
      Parameters:
      perm - the big array to be sorted.
      v - the score integer big vector used to compare the element of perm.
  • Method Details

    • count

      public long count()
      Computes the number of exchanges.

      Note that a call to this method will actually sort the permutation at creation time.

      Returns:
      the number of exchanges that will order the permutation provided at creation time using the score vector provided at creation time.