saker.build Documentation TaskDoc JavaDoc Packages
public class PartitionedEntryAccumulatorArray<K, Vimplements EntryAccumulator<K, V>
EntryAccumulator implementation that can accumulate entries for a pre-defined fixed capacity.

This class is similar to EntryAccumulatorArray, but is more suitable for use when the user expects varying, but large number of elements to be accumulated.

This class doesn't allocate the whole array for the given capacity, but does it progressively as more entries are added to it. The class divides the capacity into same sized partitions, and will allocate each partition when necessary.

This class should be used when possibly both large and small number of entries may be accumulated.

This accumulator can not be used concurrently from multiple threads.

Use one of the static create(int, int) functions to create a new instance. If the capacity is small enough, only a simpler EntryAccumulatorArray will be created, instead of partitioning the array.

KThe key type.
VThe value type.
Methods
public void
add(Entry<K, V> element)
Adds an element to the accumulator.
public static <K, V> EntryAccumulator<K, V>
create(int maxcapacity)
Creates a new entry accumulator that is capable of holding at most the specified capacity number of entries.
public static <K, V> EntryAccumulator<K, V>
create(int maxcapacity, int partitionsize)
Creates a new entry accumulator for the given maximum capacity and partition size.
public Iterator<Entry<K, V>>
Returns an iterator over elements of type T.
public void
put(K key, V value)
Adds an key-value entry pair to the accumulator.
public int
Gets the current number of accumulated elements in this accumulator.
public void add(Entry<K, V> element)
Overridden from: ElementAccumulator
Adds an element to the accumulator.
elementThe element to add.
public static <K, V> EntryAccumulator<K, V> create(int maxcapacity) throws IllegalArgumentException
Creates a new entry accumulator that is capable of holding at most the specified capacity number of entries.

This is the same as create(int, int) with using the default partition size. (4096)

KThe key type.
VThe value type.
maxcapacityThe capacity to create an accumulator for.
The created accumulator.
IllegalArgumentExceptionIf the capacity is negative.
public static <K, V> EntryAccumulator<K, V> create(int maxcapacity, int partitionsize) throws IllegalArgumentException
Creates a new entry accumulator for the given maximum capacity and partition size.

The returned accumulator is capable of holding at most the specified capacity number of entries.

KThe key type.
VThe value type.
maxcapacityThe capacity to create an accumulator for.
partitionsizeThe partition size to use for dynamically allocating the underlying arrays.
The created accumulator.
IllegalArgumentExceptionIf the capacity or partition size is negative.
public Iterator<Entry<K, V>> iterator()
Overridden from: Iterable
Returns an iterator over elements of type T.
an Iterator.
public void put(K key, V value)
Overridden from: EntryAccumulator
Adds an key-value entry pair to the accumulator.
keyThe key.
valueThe value.
public int size()
Overridden from: ElementAccumulator
Gets the current number of accumulated elements in this accumulator.
The number of elements present.