Package it.unimi.dsi.law.big.util
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 Summary
Constructors Constructor Description IntegerExchangeCounter(long[][] perm, int[][] v)
Creates a new exchange counter.IntegerExchangeCounter(long[][] perm, int[][] v, long[][] support)
Creates a new exchange counter with a provided support big array. -
Method Summary
Modifier and Type Method Description long
count()
Computes the number of exchanges.
-
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 ofperm
.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 asa
.
-
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 ofperm
.
-
-
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.
-