From d4ca769e542b2489b1e23cfcbdc3a0b7275b87cd Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 13 Apr 2020 18:40:41 -0400 Subject: Cleanup pass Cleanup pass to uniformize things --- .../src/main/java/bjc/utils/funcutils/SetUtils.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'base/src/main/java/bjc/utils/funcutils/SetUtils.java') diff --git a/base/src/main/java/bjc/utils/funcutils/SetUtils.java b/base/src/main/java/bjc/utils/funcutils/SetUtils.java index d57ac00..83c191b 100644 --- a/base/src/main/java/bjc/utils/funcutils/SetUtils.java +++ b/base/src/main/java/bjc/utils/funcutils/SetUtils.java @@ -7,17 +7,20 @@ import java.util.Set; /** * Various utility functions dealing with sets. + * * @author bjculkin * */ public class SetUtils { /** * Create a power-set (set of all subsets) of a given set. - * @param originalSet The set to create a power-set of. + * + * @param originalSet + * The set to create a power-set of. * @return The power-set of the set. */ public static Set> powerSet(Set originalSet) { - Set> sets = new HashSet>(); + Set> sets = new HashSet<>(); // Special-case empty input if (originalSet.isEmpty()) { @@ -25,18 +28,18 @@ public class SetUtils { return sets; } - List list = new ArrayList(originalSet); + List list = new ArrayList<>(originalSet); // Add original set to list. T head = list.get(0); // Trim leading element from set. - Set rest = new HashSet(list.subList(1, list.size())); + Set rest = new HashSet<>(list.subList(1, list.size())); Set> remSets = powerSet(rest); - + for (Set set : remSets) { - Set newSet = new HashSet(); + Set newSet = new HashSet<>(); // Create a new set with the removed element. newSet.add(head); @@ -51,14 +54,16 @@ public class SetUtils { /** * Utility method for set construction. - * @param elms The elements to stick in the set. + * + * @param elms + * The elements to stick in the set. * @return A set containing the specified elements. */ @SafeVarargs public static Set toSet(T... elms) { Set set = new HashSet<>(); - for(T elm : elms) { + for (T elm : elms) { set.add(elm); } -- cgit v1.2.3