@Test public void testBDDRepresentativePicker1() { BDDPacket pkt = new BDDPacket(); BDD bdd1 = pkt.getIpProtocol().value(IpProtocol.UDP); BDD bdd2 = pkt.getIpProtocol().value(IpProtocol.TCP); BDD bdd = pkt.getIpProtocol().value(IpProtocol.UDP); BDD pickedBDD = BDDRepresentativePicker.pickRepresentative(bdd, ImmutableList.of(bdd1, bdd2)); assertThat(pickedBDD.and(bdd), equalTo(pickedBDD)); }
public static @Nonnull BDD pickRepresentative(BDD bdd, List<BDD> preference) { if (bdd.isZero()) { return bdd; } BDD curBDD = bdd.id(); for (BDD preferredBDD : preference) { BDD newBDD = preferredBDD.and(curBDD); if (newBDD.isZero()) { continue; } curBDD.free(); curBDD = newBDD; } return curBDD.satOne(); }
BDDRepresentativePicker { public static @Nonnull BDD pickRepresentative(BDD bdd, List<BDD> preference) { if (bdd.isZero()) { return bdd; } BDD curBDD = bdd.id(); for (BDD preferredBDD : preference) { BDD newBDD = preferredBDD.and(curBDD); if (newBDD.isZero()) { continue; } curBDD.free(); curBDD = newBDD; } return curBDD.satOne(); } }
BDDRepresentativePicker { public static @Nonnull BDD pickRepresentative(BDD bdd, List<BDD> preference) { if (bdd.isZero()) { return bdd; } BDD curBDD = bdd.id(); for (BDD preferredBDD : preference) { BDD newBDD = preferredBDD.and(curBDD); if (newBDD.isZero()) { continue; } curBDD.free(); curBDD = newBDD; } return curBDD.satOne(); } private  BDDRepresentativePicker(); }
BDDRepresentativePicker { public static @Nonnull BDD pickRepresentative(BDD bdd, List<BDD> preference) { if (bdd.isZero()) { return bdd; } BDD curBDD = bdd.id(); for (BDD preferredBDD : preference) { BDD newBDD = preferredBDD.and(curBDD); if (newBDD.isZero()) { continue; } curBDD.free(); curBDD = newBDD; } return curBDD.satOne(); } private  BDDRepresentativePicker(); static @Nonnull BDD pickRepresentative(BDD bdd, List<BDD> preference); }
BDDRepresentativePicker { public static @Nonnull BDD pickRepresentative(BDD bdd, List<BDD> preference) { if (bdd.isZero()) { return bdd; } BDD curBDD = bdd.id(); for (BDD preferredBDD : preference) { BDD newBDD = preferredBDD.and(curBDD); if (newBDD.isZero()) { continue; } curBDD.free(); curBDD = newBDD; } return curBDD.satOne(); } private  BDDRepresentativePicker(); static @Nonnull BDD pickRepresentative(BDD bdd, List<BDD> preference);  }