Package de.tilman_neumann.jml.partitions
Class IntegerPartitionGenerator
- java.lang.Object
-
- de.tilman_neumann.jml.partitions.IntegerPartitionGenerator
-
- All Implemented Interfaces:
Generator<int[]>
,Serializable
public class IntegerPartitionGenerator extends Object implements Generator<int[]>
Integer partition generator, derived from fast multipartite number partition generator.- Author:
- Tilman Neumann
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IntegerPartitionGenerator(int n)
Complete constructor for a generator of the partitions of n
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
static void
main(String[] args)
Testint[]
next()
Compute the next partition of the input.static SortedSet<IntegerPartition>
partitionsOf(int n)
Computes the partitions of the given number.
-
-
-
Method Detail
-
hasNext
public boolean hasNext()
-
next
public int[] next()
Compute the next partition of the input. The result is an array of the parts, which is much faster than creating Multisets. The parts of a partition are sorted biggest part first; the order in which partitions appear is undefined.
-
partitionsOf
public static SortedSet<IntegerPartition> partitionsOf(int n)
Computes the partitions of the given number. This is much slower than iterating over the results of the next() method and may give memory problems for big arguments, but the result is correctly ordered and has nice String output.- Parameters:
n
-- Returns:
- partitions = SortedSet
, partition = IntegerPartition_Additive, part = Integer
-
main
public static void main(String[] args)
Test- Parameters:
args
- ignored
-
-