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