Bag implements AnyBag<Bag<T>> { @Override public void clear() { Object[] buffer = this.buffer; for (int i = 0, n = buffer.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; }
@Test public void testClear() { Bag<T> bag; bag = new Bag<T>(); bag.set(0, (T) new Object()); bag.set(1, (T) new Object()); bag.set(63, (T) new Object()); bag.clear(); assertEquals((T) null, (T) bag.get(0)); assertEquals((T) null, (T) bag.get(1)); assertEquals((T) null, (T) bag.get(63)); assertEquals(64, bag.buffer.length); Mask mask = new Mask(); bag = new Bag<T>(); bag.set(0, (T) new Object()); bag.set(1, (T) new Object()); bag.set(63, (T) new Object()); mask.set(63); mask.set(0); bag.clear(mask); assertEquals((T) null, (T) bag.get(0)); assertNotEquals((T) null, (T) bag.get(1)); assertEquals((T) null, (T) bag.get(63)); mask.set(1); mask.set(457); bag.clear(mask); assertEquals((T) null, (T) bag.get(0)); assertEquals((T) null, (T) bag.get(1)); assertEquals((T) null, (T) bag.get(63)); assertEquals(64, bag.buffer.length); }