This class can be used by multiple threads to add key-value entries to it. The implementation does not use any synchronization when inserting or retrieving entries from it. Instances of this class can be used when multiple producers need to put their results to a common container.
Good use-case for this class is when lot of threads are doing computations, and are putting their result to a common container.
Although this accumulator contains Map.Entry objects, this class doesn't work like a Map. Multiple entries can be recorded with the same key.
This class works the same way as a ConcurrentPrependAccumulator<Map.Entry<K, V>> would, but is implemented to allow users to not allocate a new Map.Entry instance for each key-value pair stored.
This class collects the elements in an prepending manner, meaning that iteration order is the reverse of the insertion order.
Iterators returned by this class are weakly consistent.
The method Map.Entry.setValue(
public | Creates a new instance without any entries. |
public | ConcurrentPrependEntryAccumulator( Creates a new instance and adds the entries from the argument map to it. |
public void | add( Adds an entry to this accumulator. |
public void | Adds all entries in the argument map to this accumulator. |
public void | addAllWithKey( Adds all values in the argument iterable to this accumulator, each one of them mapped to the specified key. |
public void | addAllWithValue( Adds all keys in the argument iterable to this accumulator, each one of them mapped to the specified value. |
public void | clear() Clears this accumulator. |
public Iterable< | Clears this accumulator and returns an iterable for the cleared entries. |
public Iterator< | Clears this accumulator and returns an iterator for the cleared entries. |
public boolean | isEmpty() Checks if there are any entries in this accumulator. |
public Iterator< | iterator() Returns an iterator over elements of type T . |
public Entry< | peek() Gets the first entry in this accumulator. |
public Entry< | take() Removes the first entry from this accumulator. |
public String | toString() Returns a string representation of the object. |
null
.null
.If the values iterable is empty, no entries are added.
null
.If the keys iterable is empty, no entries are added.
null
.The iterable will always iterate on the same entries, and modifications to this accumulator are not reflected on it.
true
if the accumulator is empty.This method doesn't remove the entry itself, but just returns it.
null
if the accumulator is empty.null
if the accumulator is empty.toString
method returns a string that
"textually represents" this object. The result should be a concise but informative representation that is easy
for a person to read. It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of
which the object is an instance, the at-sign character `@
', and the unsigned hexadecimal representation
of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())