@Override @Nonnull public IntCollection values() { return new ValueView(); }
@Override public String toString() { if (isEmpty()) return "[]"; StringBuilder sb = new StringBuilder(); int elementCount = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { sb.append(' ').append(vals[i]).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(); }
@Override @SuppressWarnings("unchecked") @Nonnull public <T> T[] toArray(@Nonnull T[] a) { int size = size(); if (a.length < size) { Class<?> elementType = a.getClass().getComponentType(); a = (T[]) java.lang.reflect.Array.newInstance(elementType, size); } if (size == 0) { if (a.length > 0) a[0] = null; return a; } int resultIndex = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { a[resultIndex++] = (T) Integer.valueOf(vals[i]); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); if (a.length > resultIndex) a[resultIndex] = null; return a; }
@Override @SuppressWarnings("unchecked") @Nonnull public <T> T[] toArray(@Nonnull T[] a) { int size = size(); if (a.length < size) { Class<?> elementType = a.getClass().getComponentType(); a = (T[]) java.lang.reflect.Array.newInstance(elementType, size); } if (size == 0) { if (a.length > 0) a[0] = null; return a; } int resultIndex = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { a[resultIndex++] = (T) Integer.valueOf(vals[i]); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); if (a.length > resultIndex) a[resultIndex] = null; return a; }
@Override public int[] toArray(int[] a) { int size = size(); if (a.length < size) a = new int[size]; if (size == 0) { if (a.length > 0) a[0] = 0; return a; } int resultIndex = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { a[resultIndex++] = vals[i]; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); if (a.length > resultIndex) a[resultIndex] = 0; return a; }
@Override public boolean forEachWhile(IntPredicate predicate) { if (predicate == null) throw new java.lang.NullPointerException(); if (isEmpty()) return true; boolean terminated = false; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { if (!predicate.test(vals[i])) { terminated = true; break; } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return !terminated; }
@Override public int[] toArray(int[] a) { int size = size(); if (a.length < size) a = new int[size]; if (size == 0) { if (a.length > 0) a[0] = 0; return a; } int resultIndex = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { a[resultIndex++] = vals[i]; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); if (a.length > resultIndex) a[resultIndex] = 0; return a; }
@Override public String toString() { if (isEmpty()) return "[]"; StringBuilder sb = new StringBuilder(); int elementCount = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { sb.append(' ').append(vals[i]).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(); }
@Override public boolean allContainingIn(IntCollection c) { if (isEmpty()) return true; boolean containsAll = true; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { if (!c.contains(vals[i])) { containsAll = false; break; } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return containsAll; }
@Override @Nonnull public Object[] toArray() { int size = size(); Object[] result = new Object[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { result[resultIndex++] = vals[i]; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
@Override public boolean forEachWhile(IntPredicate predicate) { if (predicate == null) throw new java.lang.NullPointerException(); if (isEmpty()) return true; boolean terminated = false; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { if (!predicate.test(vals[i])) { terminated = true; break; } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return !terminated; }
@Override public boolean allContainingIn(IntCollection c) { if (isEmpty()) return true; boolean containsAll = true; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { if (!c.contains(vals[i])) { containsAll = false; break; } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return containsAll; }
@Override @Nonnull public Object[] toArray() { int size = size(); Object[] result = new Object[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { result[resultIndex++] = vals[i]; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
@Override public int[] toIntArray() { int size = size(); int[] result = new int[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { result[resultIndex++] = vals[i]; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
@Override public int[] toIntArray() { int size = size(); int[] result = new int[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { result[resultIndex++] = vals[i]; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
@Override public boolean reverseRemoveAllFrom(IntSet s) { if (isEmpty() || s.isEmpty()) return false; boolean changed = false; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { changed |= s.removeInt(vals[i]); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }
@Override public boolean reverseAddAllTo(IntCollection c) { if (isEmpty()) return false; boolean changed = false; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { changed |= c.add(vals[i]); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }
@Override public boolean reverseRemoveAllFrom(IntSet s) { if (isEmpty() || s.isEmpty()) return false; boolean changed = false; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { changed |= s.removeInt(vals[i]); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }
@Override public void forEach(Consumer<? super Integer> action) { if (action == null) throw new java.lang.NullPointerException(); if (isEmpty()) return; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { action.accept(vals[i]); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); }
@Override public boolean reverseAddAllTo(IntCollection c) { if (isEmpty()) return false; boolean changed = false; int mc = modCount(); short free = freeValue; short[] keys = set; int[] vals = values; for (int i = keys.length - 1; i >= 0; i--) { if (keys[i] != free) { changed |= c.add(vals[i]); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return changed; }