@Test public void testGetOnPowerSet() { PowerSet original = new PowerSet(new boolean[] { false, false, false }); Set<PowerSet> pss = original.getOnPowerSet(0); assertEquals("Empty PowerSet has no subsets", 0, pss.size()); original.switchOn(0); pss = original.getOnPowerSet(0); assertEquals("PowerSet of size one has one subset", 1, pss.size()); for (PowerSet ps : pss) { assertEquals("The subset of PowerSet of size 1 is the empty PowerSet", 0, ps.sizeOn()); } original.switchOn(1); pss = original.getOnPowerSet(0); assertEquals("PowerSet of size two has three subsets", 3, pss.size()); for (PowerSet ps : original.getOnPowerSet(1)) { assertEquals("The subsets of PowerSet of size 2 at one distance have one active index.", 1, ps.sizeOn()); } original.switchOn(2); pss = original.getOnPowerSet(0); assertEquals("PowerSet of size three has eight subsets", 7, pss.size()); for (PowerSet ps : original.getOnPowerSet(2)) { assertEquals("The subsets of PowerSet of size 3 at one distance have two active indices.", 2, ps.sizeOn()); } }
public Set<PowerSet> getOnPowerSet(int minOn) { Set<PowerSet> sets = new HashSet<PowerSet>(); if (sizeOn() <= minOn) { return sets; } for (int p=0; p<set.length; p++){ if (set[p]){ PowerSet cs = new PowerSet(this); cs.switchOff(p); sets.add(cs); sets.addAll(cs.getOnPowerSet(minOn)); } } return sets; }
PowerSet { public Set<PowerSet> getOnPowerSet(int minOn) { Set<PowerSet> sets = new HashSet<PowerSet>(); if (sizeOn() <= minOn) { return sets; } for (int p=0; p<set.length; p++){ if (set[p]){ PowerSet cs = new PowerSet(this); cs.switchOff(p); sets.add(cs); sets.addAll(cs.getOnPowerSet(minOn)); } } return sets; } }
PowerSet { public Set<PowerSet> getOnPowerSet(int minOn) { Set<PowerSet> sets = new HashSet<PowerSet>(); if (sizeOn() <= minOn) { return sets; } for (int p=0; p<set.length; p++){ if (set[p]){ PowerSet cs = new PowerSet(this); cs.switchOff(p); sets.add(cs); sets.addAll(cs.getOnPowerSet(minOn)); } } return sets; } PowerSet(int size);  PowerSet(boolean[] set);  PowerSet(PowerSet powerSet); }
PowerSet { public Set<PowerSet> getOnPowerSet(int minOn) { Set<PowerSet> sets = new HashSet<PowerSet>(); if (sizeOn() <= minOn) { return sets; } for (int p=0; p<set.length; p++){ if (set[p]){ PowerSet cs = new PowerSet(this); cs.switchOff(p); sets.add(cs); sets.addAll(cs.getOnPowerSet(minOn)); } } return sets; } PowerSet(int size);  PowerSet(boolean[] set);  PowerSet(PowerSet powerSet); void switchOn(int i); void switchOff(int i); boolean isOn(int i); boolean isOff(int i); boolean isChild(List<PowerSet> parents); boolean isChild(PowerSet potentialParent); List<PowerSet> getChildren(List<PowerSet> invalidParents); int size(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); Set<PowerSet> getOnPowerSet(int minOn); int sizeOn(); int getDiff(PowerSet child); }
PowerSet { public Set<PowerSet> getOnPowerSet(int minOn) { Set<PowerSet> sets = new HashSet<PowerSet>(); if (sizeOn() <= minOn) { return sets; } for (int p=0; p<set.length; p++){ if (set[p]){ PowerSet cs = new PowerSet(this); cs.switchOff(p); sets.add(cs); sets.addAll(cs.getOnPowerSet(minOn)); } } return sets; } PowerSet(int size);  PowerSet(boolean[] set);  PowerSet(PowerSet powerSet); void switchOn(int i); void switchOff(int i); boolean isOn(int i); boolean isOff(int i); boolean isChild(List<PowerSet> parents); boolean isChild(PowerSet potentialParent); List<PowerSet> getChildren(List<PowerSet> invalidParents); int size(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); Set<PowerSet> getOnPowerSet(int minOn); int sizeOn(); int getDiff(PowerSet child);  }