org.egothor.duplicity.util
Class Permutation

java.lang.Object
  extended by org.egothor.duplicity.util.Permutation

public class Permutation
extends java.lang.Object

Represents a permutation of integers.

Author:
Kate�ina Dufkov�

Constructor Summary
Permutation(long id, int[] perm)
          Creates permutation object from a given array of integers.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int get(int i)
          Get the i-th permutation element.
 long getID()
           
 int getLength()
          Returns the number of elements the permutation consists of.
 int hashCode()
           
 java.lang.String toString()
          Represents permutation in condensed format.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Permutation

public Permutation(long id,
                   int[] perm)
Creates permutation object from a given array of integers.

Parameters:
perm - array of integers
Method Detail

getID

public long getID()

getLength

public int getLength()
Returns the number of elements the permutation consists of.


get

public int get(int i)
        throws java.lang.ArrayIndexOutOfBoundsException
Get the i-th permutation element.

Parameters:
i - index of requested element, should be [0 .. length()-1]
Throws:
java.lang.ArrayIndexOutOfBoundsException

toString

public java.lang.String toString()
Represents permutation in condensed format.

For example the permutation:
0  1  2  3  4  5  6  7  8  9 10
 4 10  8  2  3  0  1  5  7  6  9
would be expressed in following format:
0 -> 4,10,8,2,3,
 5 -> 0,1,5,7,6,
 10 -> 9,
The number of elements on a row is determined by the TOSTRING_ELEMENT_PER_ROW constant.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object