Package one.microstream.collections
Class Collector<E>
- java.lang.Object
-
- one.microstream.collections.Collector<E>
-
- All Implemented Interfaces:
Consumer<E>
,CapacityCarrying
,CapacityExtendable
,ExtendedCollection<E>
,OptimizableCollection
,Sized
,XAddingCollection<E>
,XPuttingCollection<E>
public final class Collector<E> extends Object implements XPuttingCollection<E>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface one.microstream.collections.types.XPuttingCollection
XPuttingCollection.Creator<E>
-
-
Constructor Summary
Constructors Constructor Description Collector(XPuttingCollection<E> collection)
-
Method Summary
Modifier and Type Method Description void
accept(E e)
boolean
add(E e)
Collector<E>
addAll(E... elements)
Collector<E>
addAll(E[] elements, int offset, int length)
Collector<E>
addAll(XGettingCollection<? extends E> elements)
long
currentCapacity()
Returns the current amount of elements this instance can hold before a storage rebuild becomes necessary.Collector<E>
ensureCapacity(long minimalCapacity)
Collector<E>
ensureFreeCapacity(long minimalFreeCapacity)
Ensures that the next minimalFreeCapacity elements can be actually added in a fast way, meaning for example no internal storage rebuild will be necessary.boolean
hasVolatileElements()
boolean
isEmpty()
boolean
isFull()
Returns true if the current capacity cannot be increased any more.long
maximumCapacity()
Returns the maximum amount of elements this carrier instance can contain.
The actual value may be depend on the configuration of the concrete instance or may depend only on the implementation of the carrier (meaning it is constant for all instances of the implementation, e.g.boolean
nullAdd()
boolean
nullAllowed()
boolean
nullPut()
long
optimize()
Optimizes the internal storage of this collection and returns the storage size of the collection after the process is complete.boolean
put(E element)
Collector<E>
putAll(E... elements)
Collector<E>
putAll(E[] elements, int offset, int length)
Collector<E>
putAll(XGettingCollection<? extends E> elements)
long
remainingCapacity()
Returns the amount of elements this carrier instance can collect before reaching its maximimum capacity.long
size()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface one.microstream.collections.interfaces.CapacityExtendable
currentFreeCapacity
-
Methods inherited from interface one.microstream.collections.types.XAddingCollection
collector
-
-
-
-
Constructor Detail
-
Collector
public Collector(XPuttingCollection<E> collection)
-
-
Method Detail
-
nullAdd
public boolean nullAdd()
- Specified by:
nullAdd
in interfaceXAddingCollection<E>
-
add
public boolean add(E e)
- Specified by:
add
in interfaceXAddingCollection<E>
-
addAll
public Collector<E> addAll(E... elements)
- Specified by:
addAll
in interfaceXAddingCollection<E>
-
addAll
public Collector<E> addAll(E[] elements, int offset, int length)
- Specified by:
addAll
in interfaceXAddingCollection<E>
-
addAll
public Collector<E> addAll(XGettingCollection<? extends E> elements)
- Specified by:
addAll
in interfaceXAddingCollection<E>
-
nullPut
public boolean nullPut()
- Specified by:
nullPut
in interfaceXPuttingCollection<E>
-
accept
public void accept(E e)
-
put
public boolean put(E element)
- Specified by:
put
in interfaceXPuttingCollection<E>
-
putAll
public Collector<E> putAll(E... elements)
- Specified by:
putAll
in interfaceXPuttingCollection<E>
-
putAll
public Collector<E> putAll(E[] elements, int offset, int length)
- Specified by:
putAll
in interfaceXPuttingCollection<E>
-
putAll
public Collector<E> putAll(XGettingCollection<? extends E> elements)
- Specified by:
putAll
in interfaceXPuttingCollection<E>
-
ensureCapacity
public Collector<E> ensureCapacity(long minimalCapacity)
- Specified by:
ensureCapacity
in interfaceCapacityExtendable
-
currentCapacity
public long currentCapacity()
Description copied from interface:CapacityExtendable
Returns the current amount of elements this instance can hold before a storage rebuild becomes necessary.For carrier implementations that don't have a concept of storage rebuilding (like linked list for example) this method returns the same value as
CapacityCarrying.maximumCapacity()
.- Specified by:
currentCapacity
in interfaceCapacityExtendable
- Returns:
- the current capacity of this instance before a rebuild is required.
-
maximumCapacity
public long maximumCapacity()
Description copied from interface:CapacityCarrying
Returns the maximum amount of elements this carrier instance can contain.
The actual value may be depend on the configuration of the concrete instance or may depend only on the implementation of the carrier (meaning it is constant for all instances of the implementation, e.g.Integer.MAX_VALUE
)- Specified by:
maximumCapacity
in interfaceCapacityCarrying
- Returns:
- the maximum amount of elements this carrier instance can contain.
-
isFull
public boolean isFull()
Description copied from interface:CapacityCarrying
Returns true if the current capacity cannot be increased any more.- Specified by:
isFull
in interfaceCapacityCarrying
-
remainingCapacity
public long remainingCapacity()
Description copied from interface:CapacityCarrying
Returns the amount of elements this carrier instance can collect before reaching its maximimum capacity.- Specified by:
remainingCapacity
in interfaceCapacityCarrying
-
ensureFreeCapacity
public Collector<E> ensureFreeCapacity(long minimalFreeCapacity)
Description copied from interface:CapacityExtendable
Ensures that the next minimalFreeCapacity elements can be actually added in a fast way, meaning for example no internal storage rebuild will be necessary.- Specified by:
ensureFreeCapacity
in interfaceCapacityExtendable
-
optimize
public long optimize()
Description copied from interface:OptimizableCollection
Optimizes the internal storage of this collection and returns the storage size of the collection after the process is complete.- Specified by:
optimize
in interfaceOptimizableCollection
- Returns:
- the storage size of the collection after the optimzation.
-
hasVolatileElements
public boolean hasVolatileElements()
- Specified by:
hasVolatileElements
in interfaceExtendedCollection<E>
-
nullAllowed
public boolean nullAllowed()
- Specified by:
nullAllowed
in interfaceExtendedCollection<E>
-
isEmpty
public boolean isEmpty() throws UnsupportedOperationException
- Specified by:
isEmpty
in interfaceSized
- Throws:
UnsupportedOperationException
-
size
public long size() throws UnsupportedOperationException
- Specified by:
size
in interfaceSized
- Throws:
UnsupportedOperationException
-
-