/** * @return true iff this set contains object */ public boolean contains(T object) { if (this == EMPTY || S == null || object == null) { return false; } int index = mapping.getMappedIndex(object); return (index == -1) ? false : S.contains(index); }
ImplicitUseIterator(UnaryOperator<PointsToSetVariable> op, PointsToSetVariable use, IntSet defs) { this.op = op; this.use = use; this.defs = defs.intIterator(); }
@Override public boolean sameValue(IntSet that) { return that.isEmpty(); }
public SparseIntSet(IntSet S) throws IllegalArgumentException { if (S == null) { throw new IllegalArgumentException("S == null"); } if (S instanceof SparseIntSet) { cloneState((SparseIntSet) S); } else { elements = new int[S.size()]; size = S.size(); S.foreach(new IntSetAction() { private int index = 0; @Override public void act(int i) { elements[index++] = i; } }); } }
public static int[] toArray(IntSet s) { int i = 0; int[] result = new int[ s.size() ]; IntIterator x = s.intIterator(); while (x.hasNext()) { result[i++] = x.next(); } assert ! x.hasNext(); return result; }
} else if (intersect.isEmpty()) { return NOT_CHANGED_AND_FIXED; final IntSet vlhs = bv.getValue(); if (vlhs != null) { intersect = intersect.intersection(vlhs); if (lhs.getValue() != null && intersect.sameValue(lhs.getValue())) { return NOT_CHANGED; } else { final BitVectorVariable bvv = new BitVectorVariable(); intersect.foreach(bvv::set); lhs.copyState(bvv);
private IntSet bits(PropagationSystem system) { IntSet f = null; for(IClass cls : concreteType) { if (f == null) { f = system.getInstanceKeysForClass(cls); } else { f = f.union(system.getInstanceKeysForClass(cls)); } } return f; }
@Test public void testSync2() { MethodReference mr = StringStuff.makeMethodReference("cfg.MonitorTest.sync2()V"); IMethod m = cha.resolveMethod(mr); IAnalysisCacheView cache = makeAnalysisCache(); IR ir = cache.getIR(m); System.out.println(ir); SSACFG controlFlowGraph = ir.getControlFlowGraph(); IntSet succs = controlFlowGraph.getSuccNodeNumbers(controlFlowGraph.getBlockForInstruction(13)); Assert.assertEquals(2, succs.size()); Assert.assertTrue(succs.contains(6)); Assert.assertTrue(succs.contains(7)); }
@Override public void removeOutgoingEdges(T node) throws IllegalArgumentException { final int number = nodeManager.getNumber(node); if (number < 0) { throw new IllegalArgumentException("node not in graph: " + node); } IntSet succ = successors.getRelated(number); if (succ != null) { succ.foreach(x -> predecessors.remove(x, number)); } successors.removeAll(number); hasSuccessor.clear(number); }
@Override public int getSuccNodeCount(T N) { if (N == null) { throw new IllegalArgumentException("N is null"); } INodeWithNumberedEdges en = N; IntSet s = en.getSuccNumbers(); return s == null ? 0 : s.size(); }
/** * @return true if the contents of two sets are equal */ public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b) { if ((a == null && b == null) || a == b || (a.mapping == b.mapping && a.S == b.S)) { return true; } assert a != null && b != null; if (a.size() == b.size()) { if (a.mapping == b.mapping || (a.mapping != null && b.mapping != null && a.mapping.equals(b.mapping))) { return a.S == b.S || (a.S != null && b.S != null && a.S.sameValue(b.S)); } } return false; }
/** * @return a new OrdinalSet instances * @throws IllegalArgumentException if A is null */ public static <T> OrdinalSet<T> intersect(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null || B.S == null) { return new OrdinalSet<>(null, A.mapping); } IntSet isect = A.S.intersection(B.S); return new OrdinalSet<>(isect, A.mapping); }
} else if (intersect.isEmpty()) { return NOT_CHANGED_AND_FIXED; final IntSet vlhs = bv.getValue(); if (vlhs != null) { intersect = intersect.intersection(vlhs); if (lhs.getValue() != null && intersect.sameValue(lhs.getValue())) { return NOT_CHANGED; } else { final BitVectorVariable bvv = new BitVectorVariable(); intersect.foreach(bvv::set); lhs.copyState(bvv);
private IntSet bits(PropagationSystem system) { IntSet f = null; for(IClass cls : concreteType) { if (f == null) { f = system.getInstanceKeysForClass(cls); } else { f = f.union(system.getInstanceKeysForClass(cls)); } } return f; }
public static int[] toArray(IntSet s) { int i = 0; int[] result = new int[ s.size() ]; IntIterator x = s.intIterator(); while (x.hasNext()) { result[i++] = x.next(); } assert ! x.hasNext(); return result; }
@Override public void removeOutgoingEdges(T node) throws IllegalArgumentException { final int number = nodeManager.getNumber(node); if (number < 0) { throw new IllegalArgumentException("node not in graph: " + node); } IntSet succ = successors.getRelated(number); if (succ != null) { succ.foreach(x -> predecessors.remove(x, number)); } successors.removeAll(number); hasSuccessor.clear(number); }
public SparseIntSet(IntSet S) throws IllegalArgumentException { if (S == null) { throw new IllegalArgumentException("S == null"); } if (S instanceof SparseIntSet) { cloneState((SparseIntSet) S); } else { elements = new int[S.size()]; size = S.size(); S.foreach(new IntSetAction() { private int index = 0; @Override public void act(int i) { elements[index++] = i; } }); } }
@Override public int getSuccNodeCount(T N) { if (N == null) { throw new IllegalArgumentException("N is null"); } INodeWithNumberedEdges en = N; IntSet s = en.getSuccNumbers(); return s == null ? 0 : s.size(); }
/** * @return true if the contents of two sets are equal */ public static <T> boolean equals(OrdinalSet<T> a, OrdinalSet<T> b) { if ((a == null && b == null) || a == b || (a.mapping == b.mapping && a.S == b.S)) { return true; } assert a != null && b != null; if (a.size() == b.size()) { if (a.mapping == b.mapping || (a.mapping != null && b.mapping != null && a.mapping.equals(b.mapping))) { return a.S == b.S || (a.S != null && b.S != null && a.S.sameValue(b.S)); } } return false; }
/** * @return a new OrdinalSet instances * @throws IllegalArgumentException if A is null */ public static <T> OrdinalSet<T> intersect(OrdinalSet<T> A, OrdinalSet<T> B) { if (A == null) { throw new IllegalArgumentException("A is null"); } if (A.size() != 0 && B.size() != 0) { assert A.mapping.equals(B.mapping); } if (A.S == null || B.S == null) { return new OrdinalSet<>(null, A.mapping); } IntSet isect = A.S.intersection(B.S); return new OrdinalSet<>(isect, A.mapping); }