liquibase.util.CollectionUtil Maven / Gradle / Ivy
package liquibase.util;
import java.util.*;
public class CollectionUtil {
public static Set> powerSet(Collection originalSet) {
Set> sets = new HashSet<>();
if (originalSet.isEmpty()) {
sets.add(new HashSet());
return sets;
}
List list = new ArrayList<>(originalSet);
T head = list.get(0);
Collection rest = list.subList(1, list.size());
for (Set set : powerSet(rest)) {
Set newSet = new HashSet<>();
newSet.add(head);
newSet.addAll(set);
sets.add(newSet);
sets.add(set);
}
return sets;
}
public static List