public boolean reverseAddAllTo(CharCollection c) { if (this.isEmpty()) return false; boolean changed = false; char free = freeValue; char[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { char key; if ((key = keys[i]) != free) { changed |= c.add(key); } } return changed; }
@Override public boolean test(char value) { return collection.contains(value); } });
public static boolean addAll(final CharCollection collection, Collection<? extends Character> another) { if (collection == another) throw new IllegalArgumentException(); long maxPossibleSize = collection.sizeAsLong() + Containers.sizeAsLong(another); collection.ensureCapacity(maxPossibleSize); if (another instanceof CharCollection) { if (another instanceof InternalCharCollectionOps) { return ((InternalCharCollectionOps) another).reverseAddAllTo(collection); } else { class AddAll implements CharConsumer { boolean collectionChanged = false; @Override public void accept(char value) { collectionChanged |= collection.add(value); } } AddAll addAll = new AddAll(); ((CharCollection) another).forEach(addAll); return addAll.collectionChanged; } } else { boolean collectionChanged = false; for (Character v : another) { collectionChanged |= collection.add(v.charValue()); } return collectionChanged; } }
public static boolean containsAll(final CharCollection collection, Collection<?> another) { if (collection == another) return true; if (another instanceof CharCollection) { CharCollection c2 = (CharCollection) another; if (collection instanceof CharSet && c2 instanceof CharSet && collection.size() < another.size()) { return false; } if (c2 instanceof InternalCharCollectionOps) { // noinspection unchecked return ((InternalCharCollectionOps) c2).allContainingIn(collection); } return c2.forEachWhile(new CharPredicate() { @Override public boolean test(char value) { return collection.contains(value); } }); } else { for (Object o : another) { if (!collection.contains(((Character) o).charValue() )) return false; } return true; } }
private boolean removeAll(CharCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; int mc = modCount(); long[] keys = set; char[] 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(CharCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; int mc = modCount(); long[] keys = set; char[] 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 CharCollection collection, Collection<?> another) { if (collection == another) return true; if (another instanceof CharCollection) { CharCollection c2 = (CharCollection) another; if (collection instanceof CharSet && c2 instanceof CharSet && collection.size() < another.size()) { return false; } if (c2 instanceof InternalCharCollectionOps) { // noinspection unchecked return ((InternalCharCollectionOps) c2).allContainingIn(collection); } return c2.forEachWhile(new CharPredicate() { @Override public boolean test(char value) { return collection.contains(value); } }); } else { for (Object o : another) { if (!collection.contains(((Character) o).charValue() )) return false; } return true; } }
private boolean removeAll(CharCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; int mc = modCount(); int[] keys = set; char[] 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(char value) { return collection.contains(value); } });
@Override public boolean reverseAddAllTo(CharCollection c) { if (this.isEmpty()) return false; boolean changed = false; long[] keys = set; char[] 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 CharCollection collection, Collection<? extends Character> another) { if (collection == another) throw new IllegalArgumentException(); long maxPossibleSize = collection.sizeAsLong() + Containers.sizeAsLong(another); collection.ensureCapacity(maxPossibleSize); if (another instanceof CharCollection) { if (another instanceof InternalCharCollectionOps) { return ((InternalCharCollectionOps) another).reverseAddAllTo(collection); } else { class AddAll implements CharConsumer { boolean collectionChanged = false; @Override public void accept(char value) { collectionChanged |= collection.add(value); } } AddAll addAll = new AddAll(); ((CharCollection) another).forEach(addAll); return addAll.collectionChanged; } } else { boolean collectionChanged = false; for (Character v : another) { collectionChanged |= collection.add(v.charValue()); } return collectionChanged; } }
private boolean removeAll(CharCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty() || c.isEmpty()) return false; boolean changed = false; int mc = modCount(); int[] keys = set; char[] 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 boolean allContainingIn(CharCollection c) { if (this.isEmpty()) return true; boolean containsAll = true; char free = freeValue; char[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { char key; if ((key = keys[i]) != free) { if (!c.contains(key)) { containsAll = false; break; } } } return containsAll; }
@Override public boolean reverseAddAllTo(CharCollection c) { if (this.isEmpty()) return false; boolean changed = false; int[] keys = set; char[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { changed |= c.add(vals[i]); } } return changed; }
private boolean retainAll(CharCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty()) return false; if (c.isEmpty()) { clear(); return true; } boolean changed = false; int mc = modCount(); long[] keys = set; char[] 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(CharCollection c) { if (this.isEmpty()) return true; boolean containsAll = true; long[] keys = set; char[] 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(CharCollection c) { if (this.isEmpty()) return false; boolean changed = false; long[] keys = set; char[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] < FREE_BITS) { changed |= c.add(vals[i]); } } return changed; }
private boolean retainAll(CharCollection c) { if (this == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty()) return false; if (c.isEmpty()) { clear(); return true; } boolean changed = false; int mc = modCount(); long[] keys = set; char[] 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(CharCollection c) { if (this.isEmpty()) return true; boolean containsAll = true; int[] keys = set; char[] 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; }
public boolean reverseAddAllTo(CharCollection c) { if (this.isEmpty()) return false; boolean changed = false; char free = freeValue; char[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { char key; if ((key = keys[i]) != free) { changed |= c.add(key); } } return changed; }