*@return the set of all subsets of the given set, except for the empty set
*/
public static <T> Set<Set<T>> parts(Set<T> set) {
MathSet<Set<T>> result = new MathSet<Set<T>>();
T[] elements = (T[])set.toArray();
SubsetGenerator subsetGen = new SubsetGenerator(set.size());
int[] subsetIndices;
while ((subsetIndices = subsetGen.nextSet()) != null) {
MathSet<T> subset = new MathSet<T>();
for (int index : subsetIndices) {
subset.add(elements[index]);
}
result.add(subset);