func nextSubset(p partitionType, idx int) int {
	id := p.SubsetId(idx)
	length := p.Len()
	for i := idx + 1; i < length; i++ {
		if p.SubsetId(i) != id {
			return i
		}
	}
	return length
}
nextSubset returns the starting index of the next subset in p.
idx is the first index of the current subset.
To iterate over all the subsets, caller should start with idx = 0.
nextSubset returns len(p) when there are no more subsets.
package store
type partitionType interface {
	Len() int
	SubsetId(index int) interface{}
}
type formPartitionType interface {
	partitionType
	Swap(i, j int)
}
func formPartition(p formPartitionType) {
	counts := make(map[interface{}]int)
	length := p.Len()
	for i := 0; i < length; i++ {
		counts[p.SubsetId(i)]++
	}
	partitionOffsets := &partitionOffsetType{
		counts: counts,
		ranges: make(map[interface{}]sliceRangeType, len(counts)),
	}
	for i := 0; i < length; i++ {
		dest := partitionOffsets.offsetOf(p.SubsetId(i), i)
		for i < dest {
			p.Swap(i, dest)
			dest = partitionOffsets.offsetOf(p.SubsetId(i), i)
		}
	}
}