@Test public void testSet() { ByteBuffer src1 = createBuffer("ABC"); cache.add(src1); ByteBuffer src2 = createBuffer("DEF"); cache.add(src2); ByteBuffer src3 = createBuffer("GHI"); cache.set(1, src3); ByteBuffer dest = cache.get(1); assertEquals(src3, dest); }
@Override public ByteBuffer set(int index, ByteBuffer src) { Objects.requireNonNull(src); if (index < getMinimumAvailableIndex() || index > getMaximumAvailableIndex()) { throw new IndexOutOfBoundsException(); } else { int position = position(index); ByteBuffer element = getElement(position); copyBuffer(src, element); return element; } }
BufferCache implements List<ByteBuffer> { @Override public ByteBuffer set(int index, ByteBuffer src) { Objects.requireNonNull(src); if (index < getMinimumAvailableIndex() || index > getMaximumAvailableIndex()) { throw new IndexOutOfBoundsException(); } else { int position = position(index); ByteBuffer element = getElement(position); copyBuffer(src, element); return element; } } }
BufferCache implements List<ByteBuffer> { @Override public ByteBuffer set(int index, ByteBuffer src) { Objects.requireNonNull(src); if (index < getMinimumAvailableIndex() || index > getMaximumAvailableIndex()) { throw new IndexOutOfBoundsException(); } else { int position = position(index); ByteBuffer element = getElement(position); copyBuffer(src, element); return element; } } BufferCache();  BufferCache(int cacheCapacity, int bufferCapacity, ByteOrder order); }
BufferCache implements List<ByteBuffer> { @Override public ByteBuffer set(int index, ByteBuffer src) { Objects.requireNonNull(src); if (index < getMinimumAvailableIndex() || index > getMaximumAvailableIndex()) { throw new IndexOutOfBoundsException(); } else { int position = position(index); ByteBuffer element = getElement(position); copyBuffer(src, element); return element; } } BufferCache();  BufferCache(int cacheCapacity, int bufferCapacity, ByteOrder order); @Override boolean add(ByteBuffer src); @Override void add(int index, ByteBuffer src); @Override boolean addAll(Collection<? extends ByteBuffer> c); @Override boolean addAll(int index, Collection<? extends ByteBuffer> c); @Override void clear(); @Override boolean contains(Object o); @Override boolean containsAll(Collection<?> c); @Override ByteBuffer get(int index); @Override int indexOf(Object o); @Override boolean isEmpty(); @Override Iterator<ByteBuffer> iterator(); @Override int lastIndexOf(Object o); @Override ListIterator<ByteBuffer> listIterator(); @Override ListIterator<ByteBuffer> listIterator(int index); @Override ByteBuffer remove(int index); @Override boolean remove(Object o); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override ByteBuffer set(int index, ByteBuffer src); @Override int size(); @Override List<ByteBuffer> subList(int fromIndex, int toIndex); @Override Object[] toArray(); @SuppressWarnings("unchecked") T[] toArray(T[] a); }
BufferCache implements List<ByteBuffer> { @Override public ByteBuffer set(int index, ByteBuffer src) { Objects.requireNonNull(src); if (index < getMinimumAvailableIndex() || index > getMaximumAvailableIndex()) { throw new IndexOutOfBoundsException(); } else { int position = position(index); ByteBuffer element = getElement(position); copyBuffer(src, element); return element; } } BufferCache();  BufferCache(int cacheCapacity, int bufferCapacity, ByteOrder order); @Override boolean add(ByteBuffer src); @Override void add(int index, ByteBuffer src); @Override boolean addAll(Collection<? extends ByteBuffer> c); @Override boolean addAll(int index, Collection<? extends ByteBuffer> c); @Override void clear(); @Override boolean contains(Object o); @Override boolean containsAll(Collection<?> c); @Override ByteBuffer get(int index); @Override int indexOf(Object o); @Override boolean isEmpty(); @Override Iterator<ByteBuffer> iterator(); @Override int lastIndexOf(Object o); @Override ListIterator<ByteBuffer> listIterator(); @Override ListIterator<ByteBuffer> listIterator(int index); @Override ByteBuffer remove(int index); @Override boolean remove(Object o); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override ByteBuffer set(int index, ByteBuffer src); @Override int size(); @Override List<ByteBuffer> subList(int fromIndex, int toIndex); @Override Object[] toArray(); @SuppressWarnings("unchecked") T[] toArray(T[] a); static final int DEFAULT_BUFFER_CAPACITY; static final int DEFAULT_CACHE_CAPACITY; }