Bag implements AnyBag<Bag<T>> { static int nextPowerOfTwo(int value) { if (value == 0) { return 1; } value--; value |= value >>> 1; value |= value >>> 2; value |= value >>> 4; value |= value >>> 8; value |= value >>> 16; return value + 1; } 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 testNextPowerOfTwo() { assertEquals(1, Bag.nextPowerOfTwo(0)); assertEquals(1, Bag.nextPowerOfTwo(1)); assertEquals(2, Bag.nextPowerOfTwo(2)); assertEquals(4, Bag.nextPowerOfTwo(3)); assertEquals(1 << 31, Bag.nextPowerOfTwo((1 << 30) + 1)); }