@Test public void testCopyPartFrom() { IntBag b0, b1; int e0 = 1, e1 = 1, e2 = 1, e3 = 1; b0 = new IntBag(); b0.set(5, e0); b0.set(14, e1); b0.set(21, e2); b1 = new IntBag(); b1.set(0, e3); b1.set(33, e0); b1.copyPartFrom(b0, 14, 1, 33); assertEquals((Integer) e1, (Integer) b1.get(1)); assertEquals((Integer) e2, (Integer) b1.get(8)); assertEquals((Integer) e3, (Integer) b1.get(0)); assertEquals((Integer) 0, (Integer) b1.get(32)); assertEquals((Integer) 0, (Integer) b1.get(33)); assertEquals((Integer) 0, (Integer) b1.get(34)); assertEquals((Integer) 0, (Integer) b1.get(35)); b0 = new IntBag(); b0.set(5, e0); b0.set(14, e1); b0.set(21, e2); b1 = new IntBag(); b1.set(0, e3); b1.copyPartFrom(b0, 14, 1, 8); assertEquals((Integer) e1, (Integer) b1.get(1)); assertEquals((Integer) e2, (Integer) b1.get(8)); assertEquals((Integer) e3, (Integer) b1.get(0)); assertEquals((Integer) 0, (Integer) b1.get(32)); assertEquals((Integer) 0, (Integer) b1.get(33)); assertEquals((Integer) 0, (Integer) b1.get(34)); assertEquals((Integer) 0, (Integer) b1.get(35)); }
@Override public void copyPartFrom(IntBag from, int fromOffset, int toOffset, int length) { ensureCapacity(toOffset + length); int maxLength = from.buffer.length - fromOffset; System.arraycopy(from.buffer, fromOffset, buffer, toOffset, Math.min(length, maxLength)); if (maxLength < length) { int[] buffer = this.buffer; for (int i = toOffset + maxLength, n = toOffset + length; i < n; i++) buffer[i] = 0; } }
IntBag implements AnyBag<IntBag> { @Override public void copyPartFrom(IntBag from, int fromOffset, int toOffset, int length) { ensureCapacity(toOffset + length); int maxLength = from.buffer.length - fromOffset; System.arraycopy(from.buffer, fromOffset, buffer, toOffset, Math.min(length, maxLength)); if (maxLength < length) { int[] buffer = this.buffer; for (int i = toOffset + maxLength, n = toOffset + length; i < n; i++) buffer[i] = 0; } } }
IntBag implements AnyBag<IntBag> { @Override public void copyPartFrom(IntBag from, int fromOffset, int toOffset, int length) { ensureCapacity(toOffset + length); int maxLength = from.buffer.length - fromOffset; System.arraycopy(from.buffer, fromOffset, buffer, toOffset, Math.min(length, maxLength)); if (maxLength < length) { int[] buffer = this.buffer; for (int i = toOffset + maxLength, n = toOffset + length; i < n; i++) buffer[i] = 0; } } IntBag(); }
IntBag implements AnyBag<IntBag> { @Override public void copyPartFrom(IntBag from, int fromOffset, int toOffset, int length) { ensureCapacity(toOffset + length); int maxLength = from.buffer.length - fromOffset; System.arraycopy(from.buffer, fromOffset, buffer, toOffset, Math.min(length, maxLength)); if (maxLength < length) { int[] buffer = this.buffer; for (int i = toOffset + maxLength, n = toOffset + length; i < n; i++) buffer[i] = 0; } } IntBag(); @Override void copyFrom(IntBag from); @Override void copyFrom(IntBag from, boolean clearExceeding); @Override void copyFrom(IntBag from, int length); @Override void copyFrom(IntBag from, int length, boolean clearExceeding); @Override void copyFrom(IntBag from, int fromOffset, int length); @Override void copyFrom(IntBag from, int fromOffset, int length, boolean clearExceeding); @Override void copyPartFrom(IntBag from, int fromOffset, int toOffset, int length); @Override void ensureCapacity(int capacity); int get(int index); void set(int index, int value); @Override void clear(); @Override void clear(Mask mask); }
IntBag implements AnyBag<IntBag> { @Override public void copyPartFrom(IntBag from, int fromOffset, int toOffset, int length) { ensureCapacity(toOffset + length); int maxLength = from.buffer.length - fromOffset; System.arraycopy(from.buffer, fromOffset, buffer, toOffset, Math.min(length, maxLength)); if (maxLength < length) { int[] buffer = this.buffer; for (int i = toOffset + maxLength, n = toOffset + length; i < n; i++) buffer[i] = 0; } } IntBag(); @Override void copyFrom(IntBag from); @Override void copyFrom(IntBag from, boolean clearExceeding); @Override void copyFrom(IntBag from, int length); @Override void copyFrom(IntBag from, int length, boolean clearExceeding); @Override void copyFrom(IntBag from, int fromOffset, int length); @Override void copyFrom(IntBag from, int fromOffset, int length, boolean clearExceeding); @Override void copyPartFrom(IntBag from, int fromOffset, int toOffset, int length); @Override void ensureCapacity(int capacity); int get(int index); void set(int index, int value); @Override void clear(); @Override void clear(Mask mask); @Experimental
    public int[] buffer; }