choco.kernel.common.util.comparator
Class AbstractSortingPermutation

java.lang.Object
  extended by choco.kernel.common.util.comparator.AbstractSortingPermutation
All Implemented Interfaces:
IPermutation, Comparator<Integer>
Direct Known Subclasses:
ConstantPermutation, IntPermutation

public abstract class AbstractSortingPermutation
extends Object
implements IPermutation, Comparator<Integer>


Field Summary
protected  boolean identity
           
static IPermutation IDENTITY
           
protected  Integer[] orderingPermutation
           
protected  Integer[] reversePermutation
           
 
Constructor Summary
AbstractSortingPermutation(int size)
           
 
Method Summary
 int[] applyPermutation(int[] source)
          apply the permutation to the integer array
<T> void
applyPermutation(List<T> source, T[] dest)
           
<T> void
applyPermutation(T[] source, T[] dest)
          apply the permutation on the source array
 int getOriginalIndex(int idx)
          return the original index of the idx-th element of the permuted array
 int getPermutationIndex(int idx)
          return the index in the permutation of the idx-th element
 boolean isIdentity()
           
 void sort(boolean reverse)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
compare, equals
 

Field Detail

IDENTITY

public static final IPermutation IDENTITY

identity

protected boolean identity

orderingPermutation

protected final Integer[] orderingPermutation

reversePermutation

protected final Integer[] reversePermutation
Constructor Detail

AbstractSortingPermutation

public AbstractSortingPermutation(int size)
Method Detail

sort

public final void sort(boolean reverse)

applyPermutation

public final <T> void applyPermutation(T[] source,
                                       T[] dest)
Description copied from interface: IPermutation
apply the permutation on the source array

Specified by:
applyPermutation in interface IPermutation
Parameters:
source - the array to be permuted
dest - the permuted array

applyPermutation

public <T> void applyPermutation(List<T> source,
                                 T[] dest)
Specified by:
applyPermutation in interface IPermutation

applyPermutation

public int[] applyPermutation(int[] source)
Description copied from interface: IPermutation
apply the permutation to the integer array

Specified by:
applyPermutation in interface IPermutation
Returns:
the permuted array

getOriginalIndex

public final int getOriginalIndex(int idx)
return the original index of the idx-th element of the permuted array

Specified by:
getOriginalIndex in interface IPermutation
Parameters:
idx - the permutation index
Returns:
the index in the original order

getPermutationIndex

public final int getPermutationIndex(int idx)
return the index in the permutation of the idx-th element

Specified by:
getPermutationIndex in interface IPermutation
Parameters:
idx - the index in the original order
Returns:
the index in the permutation

isIdentity

public final boolean isIdentity()
Specified by:
isIdentity in interface IPermutation

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.