public boolean reverseAddAllTo(ShortCollection c) { if (this.isEmpty()) return false; boolean changed = false; short free = freeValue; short[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { short key; if ((key = keys[i]) != free) { changed |= c.add(key); } } return changed; }
@Override public boolean test(short value) { return collection.contains(value); } });
public static boolean addAll(final ShortCollection collection, Collection<? extends Short> another) { if (collection == another) throw new IllegalArgumentException(); long maxPossibleSize = collection.sizeAsLong() + Containers.sizeAsLong(another); collection.ensureCapacity(maxPossibleSize); if (another instanceof ShortCollection) { if (another instanceof InternalShortCollectionOps) { return ((InternalShortCollectionOps) another).reverseAddAllTo(collection); } else { class AddAll implements ShortConsumer { boolean collectionChanged = false; @Override public void accept(short value) { collectionChanged |= collection.add(value); } } AddAll addAll = new AddAll(); ((ShortCollection) another).forEach(addAll); return addAll.collectionChanged; } } else { boolean collectionChanged = false; for (Short v : another) { collectionChanged |= collection.add(v.shortValue()); } return collectionChanged; } }
public static boolean containsAll(final ShortCollection collection, Collection<?> another) { if (collection == another) return true; if (another instanceof ShortCollection) { ShortCollection c2 = (ShortCollection) another; if (collection instanceof ShortSet && c2 instanceof ShortSet && collection.size() < another.size()) { return false; } if (c2 instanceof InternalShortCollectionOps) { // noinspection unchecked return ((InternalShortCollectionOps) c2).allContainingIn(collection); } return c2.forEachWhile(new ShortPredicate() { @Override public boolean test(short value) { return collection.contains(value); } }); } else { for (Object o : another) { if (!collection.contains(((Short) o).shortValue() )) return false; } return true; } }
private boolean removeAll(ShortCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; int mc = modCount(); int[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { if (c.contains(vals[i])) { incrementModCount(); mc++; keys[i] = REMOVED_BITS; postRemoveHook(); changed = true; } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }
private boolean removeAll(ShortCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; int mc = modCount(); int[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { if (c.contains(vals[i])) { incrementModCount(); mc++; keys[i] = REMOVED_BITS; postRemoveHook(); changed = true; } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }
public static boolean containsAll(final ShortCollection collection, Collection<?> another) { if (collection == another) return true; if (another instanceof ShortCollection) { ShortCollection c2 = (ShortCollection) another; if (collection instanceof ShortSet && c2 instanceof ShortSet && collection.size() < another.size()) { return false; } if (c2 instanceof InternalShortCollectionOps) { // noinspection unchecked return ((InternalShortCollectionOps) c2).allContainingIn(collection); } return c2.forEachWhile(new ShortPredicate() { @Override public boolean test(short value) { return collection.contains(value); } }); } else { for (Object o : another) { if (!collection.contains(((Short) o).shortValue() )) return false; } return true; } }
private boolean removeAll(ShortCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; int mc = modCount(); long[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { if (c.contains(vals[i])) { incrementModCount(); mc++; keys[i] = REMOVED_BITS; postRemoveHook(); changed = true; } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }
@Override public boolean test(short value) { return collection.contains(value); } });
@Override public boolean reverseAddAllTo(ShortCollection c) { if (this.isEmpty()) return false; boolean changed = false; int[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { changed |= c.add(vals[i]); } } return changed; }
public static boolean addAll(final ShortCollection collection, Collection<? extends Short> another) { if (collection == another) throw new IllegalArgumentException(); long maxPossibleSize = collection.sizeAsLong() + Containers.sizeAsLong(another); collection.ensureCapacity(maxPossibleSize); if (another instanceof ShortCollection) { if (another instanceof InternalShortCollectionOps) { return ((InternalShortCollectionOps) another).reverseAddAllTo(collection); } else { class AddAll implements ShortConsumer { boolean collectionChanged = false; @Override public void accept(short value) { collectionChanged |= collection.add(value); } } AddAll addAll = new AddAll(); ((ShortCollection) another).forEach(addAll); return addAll.collectionChanged; } } else { boolean collectionChanged = false; for (Short v : another) { collectionChanged |= collection.add(v.shortValue()); } return collectionChanged; } }
private boolean removeAll(ShortCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; int mc = modCount(); long[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { if (c.contains(vals[i])) { incrementModCount(); mc++; keys[i] = REMOVED_BITS; postRemoveHook(); changed = true; } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }
@Override public boolean allContainingIn(ShortCollection c) { if (this.isEmpty()) return true; boolean containsAll = true; long[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { if (!c.contains(vals[i])) { containsAll = false; break; } } } return containsAll; }
@Override public boolean reverseAddAllTo(ShortCollection c) { if (this.isEmpty()) return false; boolean changed = false; int[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { changed |= c.add(vals[i]); } } return changed; }
boolean removeAll(@Nonnull HashShortSet thisC, @Nonnull ShortCollection c) { if (thisC == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; short key; if ((key = U.getShort(tab, base + off)) != free) { if (c.contains(key)) { incrementModCount(); mc++; short key; if ((key = U.getShort(tab, base + off)) != free && key != removed) { if (c.contains(key)) { incrementModCount(); mc++;
@Override public boolean allContainingIn(ShortCollection c) { if (this.isEmpty()) return true; boolean containsAll = true; int[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { if (!c.contains(vals[i])) { containsAll = false; break; } } } return containsAll; }
@Override public boolean reverseAddAllTo(ShortCollection c) { if (this.isEmpty()) return false; boolean changed = false; long[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { changed |= c.add(vals[i]); } } return changed; }
boolean removeAll(@Nonnull HashShortSet thisC, @Nonnull ShortCollection c) { if (thisC == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; short key; if ((key = U.getShort(tab, base + off)) != free) { if (c.contains(key)) { incrementModCount(); mc++; short key; if ((key = U.getShort(tab, base + off)) != free && key != removed) { if (c.contains(key)) { incrementModCount(); mc++;
@Override public boolean allContainingIn(ShortCollection c) { if (this.isEmpty()) return true; boolean containsAll = true; long[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { if (!c.contains(vals[i])) { containsAll = false; break; } } } return containsAll; }
@Override public boolean reverseAddAllTo(ShortCollection c) { if (this.isEmpty()) return false; boolean changed = false; long[] keys = set; short[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { changed |= c.add(vals[i]); } } return changed; }