File indexing completed on 2024-04-06 12:01:12
0001 #ifndef _PartitionGenerator_H_
0002 #define _PartitionGenerator_H_
0003
0004 #include <vector>
0005
0006
0007
0008
0009
0010
0011
0012 class PartitionGenerator {
0013 public:
0014 typedef std::vector<int> Partition;
0015
0016
0017
0018 std::vector<Partition> partitions(int collectionSize, int minCollectionSize = 1) const;
0019
0020
0021
0022
0023
0024 std::vector<std::vector<Partition> > sortedPartitions(int collectionSize, int minCollectionSize = 1) const;
0025
0026 private:
0027
0028 class LessCollections {
0029 public:
0030 bool operator()(const Partition& a, const Partition& b) { return a.size() < b.size(); }
0031 };
0032 };
0033
0034 #endif