7 vector<PartitionGenerator::Partition>
11 std::vector<Partition> partitions;
14 partitions.push_back(
Partition(1, collectionSize) );
16 int first = collectionSize - minCollectionSize,
second = minCollectionSize;
17 while( first >= second ) {
19 std::vector<Partition> subPartitions = this->partitions(first, second);
20 std::vector<Partition>::iterator isub;
21 for( isub = subPartitions.begin(); isub != subPartitions.end(); isub++ ) {
24 if( sub.back() <
second )
continue;
26 copy( sub.begin(), sub.end(), partition.begin() );
27 partition[ partition.size()-1 ] =
second;
28 partitions.push_back( partition );
37 vector< std::vector<PartitionGenerator::Partition> >
39 int minCollectionSize)
const {
41 std::vector<Partition> partitions
42 = this->partitions(collectionSize, minCollectionSize);
45 std::vector< std::vector<Partition> > sortedPartitions;
46 sortedPartitions.resize(partitions.rbegin()->size());
48 for (std::vector<Partition>::const_iterator
i = partitions.begin();
49 i != partitions.end();
i++) {
50 sortedPartitions[(*i).size() - 1].push_back(*
i);
53 return sortedPartitions;
std::vector< std::vector< Partition > > sortedPartitions(int collectionSize, int minCollectionSize=1) const
U second(std::pair< T, U > const &p)
std::vector< Partition > partitions(int collectionSize, int minCollectionSize=1) const
std::vector< int > Partition