@TestClass(value="org.openscience.cdk.group.PermutationTest") 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() |
@TestMethod(value="sizeNConstructor") public Permutation(int size)
size
elements.size
- the number of elements in the permutation@TestMethod(value="valuesConstructor") public Permutation(int... values)
values
- the elements of the permutation@TestMethod(value="cloneConstructor") public Permutation(Permutation other)
other
- the other permutation@TestMethod(value="equalsTest,equalsTest_null,equalsTest_difference") public boolean equals(Object other)
@TestMethod(value="isIdentityTest") public boolean isIdentity()
@TestMethod(value="sizeTest") public int size()
@TestMethod(value="getTest") public int get(int index)
index
- the permutation value at this index.@TestMethod(value="getValuesTest") public int[] getValues()
@TestMethod(value="firstIndexDiffTest") public int firstIndexOfDifference(Permutation other)
other
- the other permutation to compare with@TestMethod(value="getOrbitTest") public List<Integer> getOrbit(int element)
element
- any element in the orbit@TestMethod(value="setTest") public void set(int index, int value)
index
- the index to set the valuevalue
- the value to set at this index@TestMethod(value="setToTest") public void setTo(Permutation other)
other
- the other permutation to useIllegalArgumentException
- thrown if the permutations are of different
size@TestMethod(value="multiplyTest") public Permutation multiply(Permutation other)
other
- the other permutation to use@TestMethod(value="invertTest") public Permutation invert()
@TestMethod(value="toCycleStringTest") public String toCycleString()
Copyright © 2014. All Rights Reserved.