Methods Summary |
---|
public void | append(byte[] array)
append(array, 0, array.length);
|
public synchronized void | append(byte[] array, int offset, int length)
while (length > 0) {
Chunk c = appendChunk(length);
int amount = Math.min(length, c.mArray.length - c.mLength);
System.arraycopy(array, offset, c.mArray, c.mLength, amount);
c.mLength += amount;
length -= amount;
offset += amount;
}
|
private android.webkit.ByteArrayBuilder$Chunk | appendChunk(int length)
if (length < mMinCapacity) {
length = mMinCapacity;
}
Chunk c;
if (mChunks.isEmpty()) {
c = obtainChunk(length);
} else {
c = mChunks.getLast();
if (c.mLength == c.mArray.length) {
c = obtainChunk(length);
}
}
return c;
|
public synchronized void | clear()
Chunk c = getFirstChunk();
while (c != null) {
releaseChunk(c);
c = getFirstChunk();
}
|
public synchronized android.webkit.ByteArrayBuilder$Chunk | getFirstChunk()The fastest way to retrieve the data is to iterate through the
chunks. This returns the first chunk. Note: this pulls the
chunk out of the queue. The caller must call releaseChunk() to
dispose of it.
if (mChunks.isEmpty()) return null;
return mChunks.removeFirst();
|
private void | init(int minCapacity)
mChunks = new LinkedList<Chunk>();
mPool = new LinkedList<Chunk>();
if (minCapacity <= 0) {
minCapacity = DEFAULT_CAPACITY;
}
mMinCapacity = minCapacity;
|
public boolean | isEmpty()
return mChunks.isEmpty();
|
private android.webkit.ByteArrayBuilder$Chunk | obtainChunk(int length)
Chunk c;
if (mPool.isEmpty()) {
c = new Chunk(length);
} else {
c = mPool.removeFirst();
}
mChunks.addLast(c);
return c;
|
public synchronized void | releaseChunk(android.webkit.ByteArrayBuilder$Chunk c)recycles chunk
c.mLength = 0;
mPool.addLast(c);
|