Introduced the capability of inserting buffers at a specific index.

This commit is contained in:
Simone Bordet 2014-08-04 12:12:19 +02:00
parent a2faa030cc
commit 1c984e680f
1 changed files with 12 additions and 2 deletions

View File

@ -75,8 +75,7 @@ public interface ByteBufferPool
public void prepend(ByteBuffer buffer, boolean recycle) public void prepend(ByteBuffer buffer, boolean recycle)
{ {
buffers.add(0, buffer); insert(0, buffer, recycle);
recycles.add(0, recycle);
} }
public void append(ByteBuffer buffer, boolean recycle) public void append(ByteBuffer buffer, boolean recycle)
@ -85,6 +84,12 @@ public interface ByteBufferPool
recycles.add(recycle); recycles.add(recycle);
} }
public void insert(int index, ByteBuffer buffer, boolean recycle)
{
buffers.add(index, buffer);
recycles.add(index, recycle);
}
public List<ByteBuffer> getByteBuffers() public List<ByteBuffer> getByteBuffers()
{ {
return buffers; return buffers;
@ -98,6 +103,11 @@ public interface ByteBufferPool
return length; return length;
} }
public int getSize()
{
return buffers.size();
}
public void recycle() public void recycle()
{ {
for (int i = 0; i < buffers.size(); ++i) for (int i = 0; i < buffers.size(); ++i)