saker.util Documentation TaskDoc JavaDoc Packages
package saker.util
public class EntryAccumulatorArray<K, Vimplements EntryAccumulator<K, V>
EntryAccumulator implementation that can accumulate entries into a pre-allocated array with a fixed capacity.

Instances of this class is created for a given capacity. At most capacity() number of entries can be added to the accumulator. When the accumulator cannot store the added element, BufferOverflowException will be thrown.

This accumulator can not be used concurrently from multiple threads.

When varying, but large number of elements are to be accumulated, consider using PartitionedEntryAccumulatorArray as that can dynamically allocate the underlying array when necessary.

KThe key type.
VThe value type.
Constructors
public
EntryAccumulatorArray(int capacity)
Creates a new instance for the given capacity.
Methods
public void
add(Entry<K, V> entry)
Adds an element to the accumulator.
public int
Gets the capacity of this accumulator.
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.
Creates a new instance for the given capacity.
capacityThe capacity.
NegativeArraySizeExceptionIf the capacity is negative.
public void add(Entry<K, V> entry) throws NullPointerException, BufferOverflowException
Adds an element to the accumulator.
NullPointerExceptionIf the entry is null.
BufferOverflowExceptionIf no more space available for storing the entry.
public int capacity()
Gets the capacity of this accumulator.

At most capacity() number of entries can be added to this instance.

The capacity.
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) throws BufferOverflowException
Adds an key-value entry pair to the accumulator.
BufferOverflowExceptionIf no more space available for storing the entry.
public int size()
Overridden from: ElementAccumulator
Gets the current number of accumulated elements in this accumulator.
The number of elements present.