/** * Returns an IntSet that contains all ints from the given Set that is mutable. Updates to the original Set or * the returned IntSet are not reflected in the other. * @param mutableSet set to copy from * @return IntSet with the values set */ public static IntSet mutableCopyFrom(Set<Integer> mutableSet) { if (mutableSet instanceof SingletonIntSet) { return mutableSet(((SingletonIntSet) mutableSet).value); } return new SmallIntSet(mutableSet); }
private void runTest(ToIntFunction<IntSet> intSetIntFunction) { insertData(); IntSet mutableSet = IntSets.mutableSet(8); int expected = 0; for (int segment : new int[] {3, 5, 23, 94, 103, 183, 201, 213}) { mutableSet.set(segment); Set<Integer> set = keys[segment]; if (set != null) { expected += set.size(); } } assertEquals(expected, intSetIntFunction.applyAsInt(mutableSet)); }