public void forEach(Consumer<? super E> action) { if (action == null) throw new java.lang.NullPointerException(); if (this.isEmpty()) return; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { action.accept(key); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); }
public int setHashCode() { int hashCode = 0; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { hashCode += nullableKeyHashCode(key); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return hashCode; }
@Nonnull public Object[] toArray() { int size = size(); Object[] result = new Object[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { result[resultIndex++] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
public boolean removeIf(Predicate<? super E> filter) { if (filter == null) throw new java.lang.NullPointerException(); if (this.isEmpty()) return false; boolean changed = false; int mc = modCount(); Object[] keys = set; int capacityMask = keys.length - 1; incrementModCount(); mc++; closeDeletion: if (((SeparateKVObjKeyMixing.mix(nullableKeyHashCode(castedKeyToShift)) - indexToShift) & capacityMask) >= shiftDistance) { if (indexToShift > indexToRemove) { firstDelayedRemoved = i; postRemoveHook(); } else { keys[i] = REMOVED; closeDelayedRemoved(firstDelayedRemoved); if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed;
public String setToString() { if (this.isEmpty()) return "[]"; StringBuilder sb = new StringBuilder(); int elementCount = 0; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { sb.append(' ').append(key != (Object) this ? key : "(this Collection)").append(','); if (++elementCount == 8) { int expectedLength = sb.length() * (size() / 8); sb.ensureCapacity(expectedLength + (expectedLength / 2)); } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); sb.setCharAt(0, '['); sb.setCharAt(sb.length() - 1, ']'); return sb.toString(); }
void closeDelayedRemoved(int firstDelayedRemoved ) { Object[] keys = set; int capacityMask = keys.length - 1; for (int i = firstDelayedRemoved; i >= 0; i--) { if (keys[i] == REMOVED) { int indexToRemove = i; int indexToShift = indexToRemove; int shiftDistance = 1; while (true) { indexToShift = (indexToShift - 1) & capacityMask; Object keyToShift; if ((keyToShift = keys[indexToShift]) == FREE) { break; } E castedKeyToShift = (E) keyToShift; if ((keyToShift != REMOVED) && (((SeparateKVObjKeyMixing.mix(nullableKeyHashCode(castedKeyToShift)) - indexToShift) & capacityMask) >= shiftDistance)) { keys[indexToRemove] = castedKeyToShift; indexToRemove = indexToShift; shiftDistance = 1; } else { shiftDistance++; } } keys[indexToRemove] = FREE; postRemoveHook(); } } }
public ObjIterator<E> iterator() { int mc = modCount(); return new NoRemovedIterator(mc); }
@Override public void clear() { int mc = modCount() + 1; super.clear(); if (mc != modCount()) throw new ConcurrentModificationException(); } }
boolean retainAll(@Nonnull HashObjSet<E> thisC, @Nonnull Collection<?> c) { if (thisC == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty()) return false; if (c.isEmpty()) { clear(); return true; int mc = modCount(); Object[] keys = set; int capacityMask = keys.length - 1; incrementModCount(); mc++; closeDeletion: if (((SeparateKVObjKeyMixing.mix(nullableKeyHashCode(castedKeyToShift)) - indexToShift) & capacityMask) >= shiftDistance) { if (indexToShift > indexToRemove) { firstDelayedRemoved = i; postRemoveHook(); } else { keys[i] = REMOVED; closeDelayedRemoved(firstDelayedRemoved); if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed;
public String setToString() { if (this.isEmpty()) return "[]"; StringBuilder sb = new StringBuilder(); int elementCount = 0; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { sb.append(' ').append(key != (Object) this ? key : "(this Collection)").append(','); if (++elementCount == 8) { int expectedLength = sb.length() * (size() / 8); sb.ensureCapacity(expectedLength + (expectedLength / 2)); } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); sb.setCharAt(0, '['); sb.setCharAt(sb.length() - 1, ']'); return sb.toString(); }
void closeDelayedRemoved(int firstDelayedRemoved ) { Object[] keys = set; int capacityMask = keys.length - 1; for (int i = firstDelayedRemoved; i >= 0; i--) { if (keys[i] == REMOVED) { int indexToRemove = i; int indexToShift = indexToRemove; int shiftDistance = 1; while (true) { indexToShift = (indexToShift - 1) & capacityMask; Object keyToShift; if ((keyToShift = keys[indexToShift]) == FREE) { break; } E castedKeyToShift = (E) keyToShift; if ((keyToShift != REMOVED) && (((SeparateKVObjKeyMixing.mix(nullableKeyHashCode(castedKeyToShift)) - indexToShift) & capacityMask) >= shiftDistance)) { keys[indexToRemove] = castedKeyToShift; indexToRemove = indexToShift; shiftDistance = 1; } else { shiftDistance++; } } keys[indexToRemove] = FREE; postRemoveHook(); } } }
public ObjCursor<E> setCursor() { int mc = modCount(); return new NoRemovedCursor(mc); }
@Override public void clear() { int mc = modCount() + 1; super.clear(); if (mc != modCount()) throw new ConcurrentModificationException(); } }
boolean retainAll(@Nonnull HashObjSet<E> thisC, @Nonnull Collection<?> c) { if (thisC == (Object) c) throw new IllegalArgumentException(); if (this.isEmpty()) return false; if (c.isEmpty()) { clear(); return true; int mc = modCount(); Object[] keys = set; int capacityMask = keys.length - 1; incrementModCount(); mc++; closeDeletion: if (((SeparateKVObjKeyMixing.mix(nullableKeyHashCode(castedKeyToShift)) - indexToShift) & capacityMask) >= shiftDistance) { if (indexToShift > indexToRemove) { firstDelayedRemoved = i; postRemoveHook(); } else { keys[i] = REMOVED; closeDelayedRemoved(firstDelayedRemoved); if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed;
public boolean reverseAddAllTo(ObjCollection<? super E> c) { if (this.isEmpty()) return false; boolean changed = false; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { changed |= c.add(key); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }
@Nonnull public Object[] toArray() { int size = size(); Object[] result = new Object[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { result[resultIndex++] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
public int setHashCode() { int hashCode = 0; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { hashCode += nullableKeyHashCode(key); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return hashCode; }
public ObjCursor<E> setCursor() { int mc = modCount(); return new NoRemovedCursor(mc); }
public boolean removeIf(Predicate<? super E> filter) { if (filter == null) throw new java.lang.NullPointerException(); if (this.isEmpty()) return false; boolean changed = false; int mc = modCount(); Object[] keys = set; int capacityMask = keys.length - 1; incrementModCount(); mc++; closeDeletion: if (((SeparateKVObjKeyMixing.mix(nullableKeyHashCode(castedKeyToShift)) - indexToShift) & capacityMask) >= shiftDistance) { if (indexToShift > indexToRemove) { firstDelayedRemoved = i; postRemoveHook(); } else { keys[i] = REMOVED; closeDelayedRemoved(firstDelayedRemoved); if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed;
public boolean reverseAddAllTo(ObjCollection<? super E> c) { if (this.isEmpty()) return false; boolean changed = false; int mc = modCount(); Object[] keys = set; for (int i = keys.length - 1; i >= 0; i--) { E key; // noinspection unchecked if ((key = (E) keys[i]) != FREE) { changed |= c.add(key); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }