public static boolean containsAll(final IntCollection collection, Collection<?> another) { if (collection == another) return true; if (another instanceof IntCollection) { IntCollection c2 = (IntCollection) another; if (collection instanceof IntSet && c2 instanceof IntSet && collection.size() < another.size()) { return false; } if (c2 instanceof InternalIntCollectionOps) { // noinspection unchecked return ((InternalIntCollectionOps) c2).allContainingIn(collection); } return c2.forEachWhile(new IntPredicate() { @Override public boolean test(int value) { return collection.contains(value); } }); } else { for (Object o : another) { if (!collection.contains(((Integer) o).intValue() )) return false; } return true; } }
public static boolean containsAll(final IntCollection collection, Collection<?> another) { if (collection == another) return true; if (another instanceof IntCollection) { IntCollection c2 = (IntCollection) another; if (collection instanceof IntSet && c2 instanceof IntSet && collection.size() < another.size()) { return false; } if (c2 instanceof InternalIntCollectionOps) { // noinspection unchecked return ((InternalIntCollectionOps) c2).allContainingIn(collection); } return c2.forEachWhile(new IntPredicate() { @Override public boolean test(int value) { return collection.contains(value); } }); } else { for (Object o : another) { if (!collection.contains(((Integer) o).intValue() )) return false; } return true; } }