auditor
Class Permutation

java.lang.Object
  extended by auditor.Permutation

public class Permutation
extends java.lang.Object

This class implements operations on permutations

Author:
felippo

Field Summary
(package private)  int length
           
(package private)  int[] perm
           
 
Constructor Summary
Permutation(int n)
          Default constructor - creates array of integers of given size
Permutation(Permutation p)
           
Permutation(java.lang.String permutation)
          For proper string of integers (separated with single spaces) transforms it into array of integers
Permutation(java.lang.String pString, int start, int pLength)
          Creates a permutation of a length equal to pLength from a given pString, starting from the start integer
 
Method Summary
 boolean Compare(Permutation b)
          Method that compares two permutation arrays.
 int getElement(int i)
          Method returns i'th element of a permutation
 int getLength()
           
 Permutation inversePerm()
          Method returns inverse permutation to the given one.
 Permutation multiplyRight(Permutation b)
          Method returns permutation which is a multiplication of a permutation a and a permutation b.
 void setElement(int i, int val)
          Method sets val into i'th element of the permutation
 java.lang.String showPerm()
          Method that creates a string with permutation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

perm

int[] perm

length

int length
Constructor Detail

Permutation

public Permutation(int n)
Default constructor - creates array of integers of given size

Parameters:
n -

Permutation

public Permutation(java.lang.String permutation)
For proper string of integers (separated with single spaces) transforms it into array of integers

Parameters:
permutation -

Permutation

public Permutation(java.lang.String pString,
                   int start,
                   int pLength)
Creates a permutation of a length equal to pLength from a given pString, starting from the start integer

Parameters:
pString -
start -
pLength -

Permutation

public Permutation(Permutation p)
Method Detail

getLength

public int getLength()

showPerm

public java.lang.String showPerm()
Method that creates a string with permutation

Returns:
String with permutation that can be displayed

getElement

public int getElement(int i)
Method returns i'th element of a permutation

Parameters:
i - - element index
Returns:
value of the i'th element

setElement

public void setElement(int i,
                       int val)
Method sets val into i'th element of the permutation

Parameters:
i -
val -

multiplyRight

public Permutation multiplyRight(Permutation b)
                          throws java.lang.Exception
Method returns permutation which is a multiplication of a permutation a and a permutation b.

Parameters:
b - Input permutation
Returns:
A permutation which is multiplication of perm and b (perm*b = perm(b))
Throws:
java.lang.Exception - If the input permutations have different length

inversePerm

public Permutation inversePerm()
Method returns inverse permutation to the given one.

Returns:
Inversion of a input permutation in (i.e. if ret = perm.inversePerm() then multiplyPerm(ret, perm) = I, where I is identity permutation)

Compare

public boolean Compare(Permutation b)
Method that compares two permutation arrays.

Parameters:
b - Second permutation to compare
Returns:
True if permutations are equal, otherwise false