CompactList implements Iterable<MutableDirectBuffer>, CloseableSilently { public int wrap(final int idx, final MutableDirectBuffer dstBuffer) { final int size = size(); boundsCheckIncludingSize(idx, size); final int elementOffset = elementOffset(framedElementLength, idx); final int length = listBuffer.getInt(elementLengthOffset(elementOffset)); dstBuffer.wrap(listBuffer, elementDataOffset(elementOffset), length); return length; } CompactList(
      final int elementMaxLength, final int capacity, final BufferAllocator bufferAllocator);  CompactList(
      final AllocatedBuffer allocatedBuffer, final int elementMaxLength, final int capacity);  CompactList(final UnsafeBuffer listBuffer); void add(final DirectBuffer srcBuffer); void add(final DirectBuffer srcBuffer, final int offset, final int length); void add(final DirectBuffer srcBuffer, final int offset, final int length, final int idx); void set(final int idx, final DirectBuffer srcBuffer); void set(final int idx, final DirectBuffer srcBuffer, final int offset, final int length); void remove(final int idx); int size(); int sizeVolatile(); int capacity(); int maxElementDataLength(); int get(final int idx, final MutableDirectBuffer dstBuffer, final int offset); int wrap(final int idx, final MutableDirectBuffer dstBuffer); int getEncodedSize(); DirectBuffer getRawBuffer(); int find(final DirectBuffer key, final Comparator<DirectBuffer> c); int copyInto(final MutableDirectBuffer dstBuffer, final int offset); void clear(); @Override CompactListIterator iterator(); InputStream toInputStream(); @Override void close();  }
@Test public void shouldExceptionWhenIndexIsNegativeWhenWrappingElement() { expectedExceptionRule.expect(IndexOutOfBoundsException.class); list.wrap(-1, readBuffer); }
@Test public void shouldExceptionIndexOutOfBoundWhenWrappingElement() { expectedExceptionRule.expect(IndexOutOfBoundsException.class); list.wrap(0, readBuffer); }
@Test public void shouldWrapElement() { addValues(); list.wrap(7, readBuffer); assertThat(readBuffer.getInt(0)).isEqualTo(7); }
@Test public void shouldChangeValueInList() { final UnsafeBuffer element = new UnsafeBuffer(new byte[SIZE_OF_INT]); addValues(); list.wrap(7, element); assertThat(element.getInt(0)).isEqualTo(7); element.putInt(0, 555); list.wrap(7, readBuffer); assertThat(readBuffer.getInt(0)).isEqualTo(555); }
@Test public void shouldReturnLengthOfAttachedElement() { addValues(); final int length = list.wrap(7, readBuffer); assertThat(length).isEqualTo(SIZE_OF_INT); }