Class RosenNumberPartitionIterator

java.lang.Object
org.hipparchus.util.RosenNumberPartitionIterator
All Implemented Interfaces:
Iterator<int[]>

public class RosenNumberPartitionIterator extends Object implements Iterator<int[]>
An iterator that generates all partitions of n elements, into k parts containing the number of elements in each part, based on Rosen's algorithm.

This is a copy of the class (with slight edits) with the same name from the Symja Library. The original file was published under the terms of the GPLV3 license, but the Hipparchus project was explicitly allowed to include it relicensed to Apache V2.

See Kenneth H. Rosen, Discrete Mathematics and Its Applications, 2nd edition (NY: McGraw-Hill, 1991), pp. 284-286

  • Constructor Details

    • RosenNumberPartitionIterator

      public RosenNumberPartitionIterator(int n, int k)
      Simple constructor.
      Parameters:
      n - the number of elements
      k - divided into k parts
  • Method Details

    • hasNext

      public final boolean hasNext()
      Specified by:
      hasNext in interface Iterator<int[]>
      See Also:
    • next

      public final int[] next()
      Specified by:
      next in interface Iterator<int[]>
      See Also:
    • reset

      public void reset()
      Reset this iterator to the start condition.