public class Permutation extends Object
Constructor and Description |
---|
Permutation(int... map)
Create a new permutations which maps
i to map[i]
for each i . |
Permutation(int n,
int[][] cycles)
Use the notation
(0 1) (4 5 6) to represent the permutation
(1 0 2 3 5 6 4) |
Modifier and Type | Method and Description |
---|---|
static Iterable<Permutation> |
all(int n)
Return all permutations of the sequence
( 0, 1, ... |
Permutation |
and(Permutation then)
Permutation composition
|
boolean |
equals(Object o) |
static int[] |
from0toN(int n) |
int |
get(int i)
The ith slot from the permutation
|
int |
hashCode() |
Permutation |
inverse()
The inverse permutation
|
static void |
main(String[] argv)
simple test
|
int[] |
mapAll(int... args)
For each of the arguments, which must be between 0 and
n()
map it to the new value under this permutation. |
int |
n()
The number of items being permuted by this permutation.
|
<T> T[] |
permute(T... args)
This method returns the permuted arguments, which
must be of number
n() |
int[] |
toArray()
The permutation as an array of integers.
|
String |
toString() |
public Permutation(int... map)
i
to map[i]
for each i
.map
- The numbers 0 to map.length - 1
in an arbitrary order.public Permutation(int n, int[][] cycles)
(0 1) (4 5 6)
to represent the permutation
(1 0 2 3 5 6 4)
n
- ( 0, 1, ... n - 1)
cycles
- A list of cycles in the permutation to be created.public static Iterable<Permutation> all(int n)
( 0, 1, ... n - 1)
n
- public static int[] from0toN(int n)
public int[] toArray()
public int get(int i)
i
- An integer from 0
to n - 1
public <T> T[] permute(T... args)
n()
args
- public int[] mapAll(int... args)
n()
map it to the new value under this permutation. get(int)
is the same as this method on one argument.args
- public Permutation inverse()
public Permutation and(Permutation then)
then
- Perform this
permutation and then then
public int n()
public static void main(String[] argv)
argv
- the string representation of n