This class returns the indexes for partitioning a list of N elements.
Usage pattern:
final KPartitionsIterable iter = new KPartitionsIterable(n, k);
for (int[] partitionsIndex : iter) {
...
}
Example: KPartitionsIterable(3,5) gives the following sequences [0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 3], [0, 2, 4], [0, 3,
4]
If you interpret these integer lists as indexes for a list {a,b,c,d,e} which should be partitioned into 3 parts the results
are:
{{{a},{b},{c,d,e}}, {{a},{b,c},{d,e}}, {{a},{b,c,d},{e}}, {{a,b},{c},{d,e}}, {{a,b},{c,d},{e}}, {{a,b,c},{d},{e}}}
See
Wikipedia - Partition of a set