public final class FastByteArrayProvider extends Object
capacity
arrays of
different lengths can be stored, quickly retrievable with the getArray(int)
method. Frequently requested
arrays will be returned faster, less frequently used arrays might have to be initialized first and are more likely to
be removed.Constructor and Description |
---|
FastByteArrayProvider(int capacity)
The constructor.
|
public FastByteArrayProvider(int capacity)
capacity
- the capacity
of the created object.public byte[] getArray(int length)
Note that the returned array may have been used before and therefore the array's values are not guaranteed to be
0
.
The method consecutively checks arrays
for an array of the correct length. If such an array exists, it
will be moved to one index position closer to the front of the array (if possible), speeding up future retrievals
of the same array.
length
- the length of the returned arraypublic byte[][] getAll()
This method's primary purpose is to enable testing of byte array storing and reordering.
arrays
.Copyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.