Package de.tilman_neumann.jml.partitions
Class IntegerPartitionGenerator
java.lang.Object
de.tilman_neumann.jml.partitions.IntegerPartitionGenerator
- All Implemented Interfaces:
Generator<int[]>
,java.io.Serializable
public class IntegerPartitionGenerator extends java.lang.Object implements Generator<int[]>
Integer partition generator, derived from fast multipartite number partition generator.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description IntegerPartitionGenerator(int n)
Complete constructor for a generator of the partitions of n -
Method Summary
Modifier and Type Method Description boolean
hasNext()
static void
main(java.lang.String[] args)
Testint[]
next()
Compute the next partition of the input.static java.util.SortedSet<IntegerPartition>
partitionsOf(int n)
Computes the partitions of the given number.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
IntegerPartitionGenerator
public IntegerPartitionGenerator(int n)Complete constructor for a generator of the partitions of n- Parameters:
n
-
-
-
Method Details
-
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
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(java.lang.String[] args)Test- Parameters:
args
- ignored
-