generator.engin.utils
Class PartitionInteger

java.lang.Object
  extended by generator.engin.utils.PartitionInteger

public class PartitionInteger
extends java.lang.Object

PartitionInteger

This class is used to split an integer number into several smaller numbers for which the sum equals the original number. Some numbers can be null. This class cannot be instancied as the only method it contains is static.

Copyright(c) 2005 Université Laval, LSFM research group.

Version:
1.0
Author:
Frédérick Lemay
See Also:
Partition

Constructor Summary
PartitionInteger()
           
 
Method Summary
static java.util.ArrayList divide(int number, int numberOfParts)
          This method will split an integer number into several smaller numbers for which the sum equals the original number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartitionInteger

public PartitionInteger()
Method Detail

divide

public static java.util.ArrayList divide(int number,
                                         int numberOfParts)
                                  throws PartitionException
This method will split an integer number into several smaller numbers for which the sum equals the original number. No part may be negative, but they may be null.
For example, splitting 2 in 8 parts is legal. There will however be 6 or 7 null numbers.

Parameters:
number - the integer number to split
numberOfParts - the number of parts the number shall be split
Returns:
an array containing the generated numbers
Throws:
PartitionException - should the algorithm fail