/** * Return a new FixedSizeBitVector as the OR of two others * * @throws IllegalArgumentException if b2 == null */ public static FixedSizeBitVector or(FixedSizeBitVector b1, FixedSizeBitVector b2) throws IllegalArgumentException { if (b2 == null) { throw new IllegalArgumentException("b2 == null"); } FixedSizeBitVector b = new FixedSizeBitVector(b1); b.or(b2); return b; }
/** * Return a new bit string as the AND of two others. */ public static FixedSizeBitVector and(FixedSizeBitVector b1, FixedSizeBitVector b2) { FixedSizeBitVector b = new FixedSizeBitVector(b1); b.and(b2); return b; }
/** * Return the NOT of a bit string */ public static FixedSizeBitVector not(FixedSizeBitVector s) { FixedSizeBitVector b = new FixedSizeBitVector(s); b.not(); return b; }
@Override public int getPredNodeCount(T N) { if (N == null) { throw new IllegalArgumentException("N is null"); } if (N.equals(exit())) { // TODO: cache if necessary FixedSizeBitVector x = FixedSizeBitVector.or(normalToExit, exceptionalToExit); return x.populationCount(); } else { boolean normalIn = getNumberOfNormalIn(N) > 0; boolean exceptionalIn = getNumberOfExceptionalIn(N) > 0; if (normalIn) { if (exceptionalIn) { return Iterator2Collection.toSet(getPredNodes(N)).size(); } else { return getNumberOfNormalIn(N); } } else { return getNumberOfExceptionalIn(N); } } }
/** * Clears a bit. * * @param bit the bit to be cleared */ public void clear(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] &= ~(1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit: " + bit, e); } }
/** * subclasses must call this before calling addEdge, but after creating the nodes */ protected void init() { normalToExit = new FixedSizeBitVector(getMaxNumber() + 1); exceptionalToExit = new FixedSizeBitVector(getMaxNumber() + 1); fallThru = new FixedSizeBitVector(getMaxNumber() + 1); exit = getNode(getMaxNumber()); }
/** * @throws IllegalArgumentException if src or dst is null */ public void addNormalEdge(T src, T dst) { if (src == null) { throw new IllegalArgumentException("src is null"); } if (dst == null) { throw new IllegalArgumentException("dst is null"); } if (dst.equals(exit())) { normalToExit.set(getNumber(src)); } else if (getNumber(dst) == (getNumber(src) + 1)) { fallThru.set(getNumber(src)); } else { normalEdgeManager.addEdge(src, dst); } }
/** * Creates a copy of a Bit String * * @param s the string to copy * @throws IllegalArgumentException if s is null */ public FixedSizeBitVector(FixedSizeBitVector s) { if (s == null) { throw new IllegalArgumentException("s is null"); } bits = new int[s.bits.length]; this.nbits = s.nbits; copyBits(s); }
/** * Return the NOT of a bit string */ public static FixedSizeBitVector not(FixedSizeBitVector s) { FixedSizeBitVector b = new FixedSizeBitVector(s); b.not(); return b; }
@Override public int getPredNodeCount(T N) { if (N == null) { throw new IllegalArgumentException("N is null"); } if (N.equals(exit())) { // TODO: cache if necessary FixedSizeBitVector x = FixedSizeBitVector.or(normalToExit, exceptionalToExit); return x.populationCount(); } else { boolean normalIn = getNumberOfNormalIn(N) > 0; boolean exceptionalIn = getNumberOfExceptionalIn(N) > 0; if (normalIn) { if (exceptionalIn) { return Iterator2Collection.toSet(getPredNodes(N)).size(); } else { return getNumberOfNormalIn(N); } } else { return getNumberOfExceptionalIn(N); } } }
/** * Clears a bit. * * @param bit the bit to be cleared */ public void clear(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] &= ~(1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit: " + bit, e); } }
/** * subclasses must call this before calling addEdge, but after creating the nodes */ protected void init() { normalToExit = new FixedSizeBitVector(getMaxNumber() + 1); exceptionalToExit = new FixedSizeBitVector(getMaxNumber() + 1); fallThru = new FixedSizeBitVector(getMaxNumber() + 1); exit = getNode(getMaxNumber()); }
/** * @throws IllegalArgumentException if src or dst is null */ public void addNormalEdge(T src, T dst) { if (src == null) { throw new IllegalArgumentException("src is null"); } if (dst == null) { throw new IllegalArgumentException("dst is null"); } if (dst.equals(exit())) { normalToExit.set(getNumber(src)); } else if (getNumber(dst) == (getNumber(src) + 1)) { fallThru.set(getNumber(src)); } else { normalEdgeManager.addEdge(src, dst); } }
/** * Creates a copy of a Bit String * * @param s the string to copy * @throws IllegalArgumentException if s is null */ public FixedSizeBitVector(FixedSizeBitVector s) { if (s == null) { throw new IllegalArgumentException("s is null"); } bits = new int[s.bits.length]; this.nbits = s.nbits; copyBits(s); }
/** * Return a new FixedSizeBitVector as the OR of two others * * @throws IllegalArgumentException if b2 == null */ public static FixedSizeBitVector or(FixedSizeBitVector b1, FixedSizeBitVector b2) throws IllegalArgumentException { if (b2 == null) { throw new IllegalArgumentException("b2 == null"); } FixedSizeBitVector b = new FixedSizeBitVector(b1); b.or(b2); return b; }
/** * Return a new bit string as the AND of two others. */ public static FixedSizeBitVector and(FixedSizeBitVector b1, FixedSizeBitVector b2) { FixedSizeBitVector b = new FixedSizeBitVector(b1); b.and(b2); return b; }
/** * Return the NOT of a bit string */ public static FixedSizeBitVector not(FixedSizeBitVector s) { FixedSizeBitVector b = new FixedSizeBitVector(s); b.not(); return b; }
/** * Clears a bit. * * @param bit the bit to be cleared */ public void clear(int bit) { try { int shiftBits = bit & LOW_MASK; bits[subscript(bit)] &= ~(1 << shiftBits); } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid bit: " + bit, e); } }