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