public static IntSet make(Set<Integer> x) { int[] vals = new int[ x.size() ]; Iterator<Integer> vs = x.iterator(); for(int i = 0; i < vals.length; i++) { vals[i] = vs.next(); } return make(vals); }
/** * Compute the asymmetric difference of two sets, a \ b. */ public static IntSet diff(IntSet A, IntSet B) { if (A == null) { throw new IllegalArgumentException("null A"); } if (B == null) { throw new IllegalArgumentException("null B"); } return diff(A, B, IntSetUtil.getDefaultIntSetFactory()); }
/** * @throws IllegalArgumentException if x is null */ public BimodalMutableIntSet(BimodalMutableIntSet x) { if (x == null) { throw new IllegalArgumentException("x is null"); } impl = IntSetUtil.makeMutableCopy(x.impl); assert impl instanceof BitVectorIntSet || impl instanceof MutableSparseIntSet; }
/** * @param constParams if non-null, then constParams[i] holds the String constant that is passed as param i, or null if param i * is not a String constant */ DispatchOperator(SSAAbstractInvokeInstruction call, CGNode node, InstanceKey[][] constParams, PointerKey uniqueCatch, IntSet dispatchIndices) { this.call = call; this.node = node; this.constParams = constParams; this.uniqueCatch = uniqueCatch; this.dispatchIndices = IntSetUtil.toArray(dispatchIndices); // we better always be interested in the receiver // assert this.dispatchIndices[0] == 0; previousPtrs = new MutableIntSet[dispatchIndices.size()]; for(int i = 0; i < previousPtrs.length; i++) { previousPtrs[i] = IntSetUtil.getDefaultIntSetFactory().make(); } }
return new SemiSparseMutableIntSet((SemiSparseMutableIntSet) set); } else if (set instanceof DebuggingMutableIntSet) { MutableIntSet pCopy = makeMutableCopy(((DebuggingMutableIntSet) set).primaryImpl); MutableIntSet sCopy = makeMutableCopy(((DebuggingMutableIntSet) set).secondaryImpl); return new DebuggingMutableIntSet(pCopy, sCopy); } else if (set instanceof EmptyIntSet) { return IntSetUtil.make(); } else { Assertions.UNREACHABLE(set.getClass().toString());
/** * Keep this method private .. this returns the actual backing set for the class, which we do not want to expose to clients. */ private MutableIntSet findOrCreateSparseSetForClass(IClass klass) { assert klass.getReference() != TypeReference.JavaLangObject; MutableIntSet result = class2InstanceKey.get(klass); if (result == null) { result = IntSetUtil.getDefaultIntSetFactory().make(); class2InstanceKey.put(klass, result); } return result; }
ret = IntSetUtil.add(ret, element); return EmptyIntSet.instance; case 1: return IntSetUtil.make(new int[] { 0, 1 }); case 2: logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector()); return IntSetUtil.make(new int[] { 0, 1, 2 }); case 3: logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector()); return IntSetUtil.make(new int[] { 0, 1, 2, 3 }); case 4: logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector()); return IntSetUtil.make(new int[] { 0, 1, 2, 3, 4 }); default: logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector()); return IntSetUtil.make(new int[] { 0, 1, 2, 3, 4, 5 }); return IntSetUtil.make(new int[] { 0 }); } else { return IntSetUtil.make(new int[] { 0, 1 }); return IntSetUtil.make(new int[] { 0, 1 }); } else if (target.getSelector().equals(Selector.make("setAction(Ljava/lang/String;)Landroid/content/Intent;"))) { return IntSetUtil.make(new int[] { 0, 1 }); } else if (target.getSelector().equals(Selector.make("setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;"))) { return IntSetUtil.make(new int[] { 0 }); } else if (target.getSelector().equals(Selector.make("setClass(Landroid/content/Context;Ljava/lang/Class;)Landroid/content/Intent;"))) {
@Override public boolean addInverseFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { IntSet f = system.getInstanceKeysForClass(concreteType); // SJF: this is horribly inefficient. we really don't want to do // diffs in here. TODO: fix it. probably keep not(f) cached and // use addAllInIntersection return (f == null) ? L.addAll(R) : L.addAll(IntSetUtil.diff(R.getValue(), f)); }
private void runBitsetTest(MutableIntSetFactory<?> p, MutableIntSetFactory<?> s) throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { MutableIntSetFactory<?> save = IntSetUtil.getDefaultIntSetFactory(); try { IntSetUtil.setDefaultIntSetFactory(new DebuggingMutableIntSetFactory(p, s)); graphTest.testJLex(); } finally { IntSetUtil.setDefaultIntSetFactory(save); } }
/** * Does this set contain value x? * */ @Override public final boolean contains(int x) { if (elements == null) { return false; } return IntSetUtil.binarySearch(elements, x, 0, size - 1) >= 0; }
return new SemiSparseMutableIntSet((SemiSparseMutableIntSet) set); } else if (set instanceof DebuggingMutableIntSet) { MutableIntSet pCopy = makeMutableCopy(((DebuggingMutableIntSet) set).primaryImpl); MutableIntSet sCopy = makeMutableCopy(((DebuggingMutableIntSet) set).secondaryImpl); return new DebuggingMutableIntSet(pCopy, sCopy); } else if (set instanceof EmptyIntSet) { return IntSetUtil.make(); } else { Assertions.UNREACHABLE(set.getClass().toString());
/** * Keep this method private .. this returns the actual backing set for the class, which we do not want to expose to clients. */ private MutableIntSet findOrCreateSparseSetForClass(IClass klass) { assert klass.getReference() != TypeReference.JavaLangObject; MutableIntSet result = class2InstanceKey.get(klass); if (result == null) { result = IntSetUtil.getDefaultIntSetFactory().make(); class2InstanceKey.put(klass, result); } return result; }
ret = IntSetUtil.add(ret, element); return EmptyIntSet.instance; case 1: return IntSetUtil.make(new int[] { 0, 1 }); case 2: logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector()); return IntSetUtil.make(new int[] { 0, 1, 2 }); case 3: logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector()); return IntSetUtil.make(new int[] { 0, 1, 2, 3 }); case 4: logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector()); return IntSetUtil.make(new int[] { 0, 1, 2, 3, 4 }); default: logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector()); return IntSetUtil.make(new int[] { 0, 1, 2, 3, 4, 5 }); return IntSetUtil.make(new int[] { 0 }); } else { return IntSetUtil.make(new int[] { 0, 1 }); return IntSetUtil.make(new int[] { 0, 1 }); } else if (target.getSelector().equals(Selector.make("setAction(Ljava/lang/String;)Landroid/content/Intent;"))) { return IntSetUtil.make(new int[] { 0, 1 }); } else if (target.getSelector().equals(Selector.make("setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;"))) { return IntSetUtil.make(new int[] { 0 }); } else if (target.getSelector().equals(Selector.make("setClass(Landroid/content/Context;Ljava/lang/Class;)Landroid/content/Intent;"))) {
@Override public boolean addInverseFiltered(PropagationSystem system, PointsToSetVariable L, PointsToSetVariable R) { IntSet f = bits(system); // SJF: this is horribly inefficient. we really don't want to do // diffs in here. TODO: fix it. probably keep not(f) cached and // use addAllInIntersection return (f == null) ? L.addAll(R) : L.addAll(IntSetUtil.diff(R.getValue(), f)); }
/** * @param constParams if non-null, then constParams[i] holds the String constant that is passed as param i, or null if param i * is not a String constant */ DispatchOperator(SSAAbstractInvokeInstruction call, CGNode node, InstanceKey[][] constParams, PointerKey uniqueCatch, IntSet dispatchIndices) { this.call = call; this.node = node; this.constParams = constParams; this.uniqueCatch = uniqueCatch; this.dispatchIndices = IntSetUtil.toArray(dispatchIndices); // we better always be interested in the receiver // assert this.dispatchIndices[0] == 0; previousPtrs = new MutableIntSet[dispatchIndices.size()]; for(int i = 0; i < previousPtrs.length; i++) { previousPtrs[i] = IntSetUtil.getDefaultIntSetFactory().make(); } }
/** * Does this set contain value x? * */ @Override public final boolean contains(int x) { if (elements == null) { return false; } return IntSetUtil.binarySearch(elements, x, 0, size - 1) >= 0; }
public static IntSet make(Set<Integer> x) { int[] vals = new int[ x.size() ]; Iterator<Integer> vs = x.iterator(); for(int i = 0; i < vals.length; i++) { vals[i] = vs.next(); } return make(vals); }
return new SemiSparseMutableIntSet((SemiSparseMutableIntSet) set); } else if (set instanceof DebuggingMutableIntSet) { MutableIntSet pCopy = makeMutableCopy(((DebuggingMutableIntSet) set).primaryImpl); MutableIntSet sCopy = makeMutableCopy(((DebuggingMutableIntSet) set).secondaryImpl); return new DebuggingMutableIntSet(pCopy, sCopy); } else if (set instanceof EmptyIntSet) { return IntSetUtil.make(); } else { Assertions.UNREACHABLE(set.getClass().toString());
/** * @return a set of integers representing the instance keys that correspond to a given class. This method creates a new set, which * the caller may bash at will. */ MutableIntSet cloneInstanceKeysForClass(IClass klass) { assert klass.getReference() != TypeReference.JavaLangObject; MutableIntSet set = class2InstanceKey.get(klass); if (set == null) { return IntSetUtil.getDefaultIntSetFactory().make(); } else { // return a copy. return IntSetUtil.getDefaultIntSetFactory().makeCopy(set); } }
/** * @throws IllegalArgumentException if x is null */ public BimodalMutableIntSet(BimodalMutableIntSet x) { if (x == null) { throw new IllegalArgumentException("x is null"); } impl = IntSetUtil.makeMutableCopy(x.impl); assert impl instanceof BitVectorIntSet || impl instanceof MutableSparseIntSet; }