public final class Permutation extends Object
Constructor and Description |
---|
Permutation(int... values)
Make a permutation from a set of values such that p[i] = x for
the value x at position i.
|
Permutation(int size)
Constructs an identity permutation with
size elements. |
Permutation(Permutation other)
Construct a permutation from another one by cloning the values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
int |
firstIndexOfDifference(Permutation other)
Find an r such that this[r] != other[r].
|
int |
get(int index)
Get the value at this index.
|
List<Integer> |
getOrbit(int element)
Get all the elements in the same orbit in the permutation (unsorted).
|
int[] |
getValues()
Get all the values as an array.
|
int |
hashCode() |
Permutation |
invert()
Invert the permutation, so that for all i : inv[p[i]] = i.
|
boolean |
isIdentity()
Check to see if this permutation is the identity permutation.
|
Permutation |
multiply(Permutation other)
Multiply this permutation by another such that for all i,
this[i] = this[other[i]].
|
void |
set(int index,
int value)
Set the value at the specified index.
|
void |
setTo(Permutation other)
Alter a permutation by setting it to the values in the other permutation.
|
int |
size()
Get the number of elements in the permutation.
|
String |
toCycleString()
An easily-readable version of the permutation as a product of cycles.
|
String |
toString() |
public Permutation(int size)
size
elements.size
- the number of elements in the permutationpublic Permutation(int... values)
values
- the elements of the permutationpublic Permutation(Permutation other)
other
- the other permutationpublic boolean isIdentity()
public int size()
public int get(int index)
index
- the permutation value at this index.public int[] getValues()
public int firstIndexOfDifference(Permutation other)
other
- the other permutation to compare withpublic List<Integer> getOrbit(int element)
element
- any element in the orbitpublic void set(int index, int value)
index
- the index to set the valuevalue
- the value to set at this indexpublic void setTo(Permutation other)
other
- the other permutation to useIllegalArgumentException
- thrown if the permutations are of different
sizepublic Permutation multiply(Permutation other)
other
- the other permutation to usepublic Permutation invert()
public String toCycleString()
Copyright © 2018. All Rights Reserved.