@Test public void toIntArray() { IntSet emptySet = new BitSetIntSet(); int[] emptyArr = emptySet.toIntArray(); assertThat(emptyArr.length, is(0)); IntSet withGapsSet = new BitSetIntSet(100, Arrays.asList(43, 23, 53)); int[] arr = withGapsSet.toIntArray(); assertThat(arr.length, is(3)); assertThat(arr[0], is(23)); assertThat(arr[1], is(43)); assertThat(arr[2], is(53)); }
@Override public int[] toIntArray() { if (size == 0) return EMPTY_INTS; int[] arr = new int[size]; for (int i = 0, pos = -1; i < size; i++) { pos = bitSet.nextSetBit(pos + 1); arr[i] = pos; } return arr; }
BitSetIntSet extends GridSerializableCollection<Integer> implements IntSet { @Override public int[] toIntArray() { if (size == 0) return EMPTY_INTS; int[] arr = new int[size]; for (int i = 0, pos = -1; i < size; i++) { pos = bitSet.nextSetBit(pos + 1); arr[i] = pos; } return arr; } }
BitSetIntSet extends GridSerializableCollection<Integer> implements IntSet { @Override public int[] toIntArray() { if (size == 0) return EMPTY_INTS; int[] arr = new int[size]; for (int i = 0, pos = -1; i < size; i++) { pos = bitSet.nextSetBit(pos + 1); arr[i] = pos; } return arr; } BitSetIntSet();  BitSetIntSet(int initCap);  BitSetIntSet(int initCap, Collection<Integer> coll); }
BitSetIntSet extends GridSerializableCollection<Integer> implements IntSet { @Override public int[] toIntArray() { if (size == 0) return EMPTY_INTS; int[] arr = new int[size]; for (int i = 0, pos = -1; i < size; i++) { pos = bitSet.nextSetBit(pos + 1); arr[i] = pos; } return arr; } BitSetIntSet();  BitSetIntSet(int initCap);  BitSetIntSet(int initCap, Collection<Integer> coll); @Override int size(); @Override boolean contains(Object o); @Override boolean contains(int element); @NotNull @Override Iterator<Integer> iterator(); @Override boolean add(Integer integer); @Override boolean add(int element); @Override boolean remove(Object o); @Override boolean remove(int element); @Override int[] toIntArray(); @Override boolean containsAll(@NotNull Collection<?> c); @Override boolean addAll(@NotNull Collection<? extends Integer> c); @Override boolean retainAll(@NotNull Collection<?> c); @Override boolean removeAll(@NotNull Collection<?> c); @Override void clear(); }
BitSetIntSet extends GridSerializableCollection<Integer> implements IntSet { @Override public int[] toIntArray() { if (size == 0) return EMPTY_INTS; int[] arr = new int[size]; for (int i = 0, pos = -1; i < size; i++) { pos = bitSet.nextSetBit(pos + 1); arr[i] = pos; } return arr; } BitSetIntSet();  BitSetIntSet(int initCap);  BitSetIntSet(int initCap, Collection<Integer> coll); @Override int size(); @Override boolean contains(Object o); @Override boolean contains(int element); @NotNull @Override Iterator<Integer> iterator(); @Override boolean add(Integer integer); @Override boolean add(int element); @Override boolean remove(Object o); @Override boolean remove(int element); @Override int[] toIntArray(); @Override boolean containsAll(@NotNull Collection<?> c); @Override boolean addAll(@NotNull Collection<? extends Integer> c); @Override boolean retainAll(@NotNull Collection<?> c); @Override boolean removeAll(@NotNull Collection<?> c); @Override void clear();  }