Package one.microstream.collections
Class SynchAdder<E>
java.lang.Object
one.microstream.collections.SynchAdder<E>
- All Implemented Interfaces:
Consumer<E>,CapacityCarrying,CapacityExtendable,ExtendedCollection<E>,OptimizableCollection,Sized,XAddingCollection<E>,Synchronized,ThreadSafe
public final class SynchAdder<E> extends Object implements XAddingCollection<E>, Synchronized
-
Nested Class Summary
Nested classes/interfaces inherited from interface one.microstream.collections.types.XAddingCollection
XAddingCollection.Creator<E> -
Constructor Summary
Constructors Constructor Description SynchAdder(XAddingCollection<E> collection) -
Method Summary
Modifier and Type Method Description voidaccept(E e)booleanadd(E e)Adds the passed element.SynchAdder<E>addAll(E... elements)SynchAdder<E>addAll(E[] elements, int offset, int length)SynchAdder<E>addAll(XGettingCollection<? extends E> elements)longcurrentCapacity()Returns the current amount of elements this instance can hold before a storage rebuild becomes necessary.SynchAdder<E>ensureCapacity(long minimalCapacity)SynchAdder<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.booleanhasVolatileElements()Tells if this collection contains volatile elements.
An element is volatile, if it can become no longer reachable by the collection without being removed from the collection.booleanisEmpty()booleanisFull()Returns true if the current capacity cannot be increased any more.longmaximumCapacity()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.booleannullAdd()booleannullAllowed()Defines if null-elements are allowed inside the collection or not.longoptimize()Optimizes the internal storage of this collection and returns the storage size of the collection after the process is complete.longremainingCapacity()Returns the amount of elements this carrier instance can collect before reaching its maximimum capacity.longsize()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface one.microstream.collections.interfaces.CapacityExtendable
currentFreeCapacity
-
Constructor Details
-
Method Details
-
nullAdd
public final boolean nullAdd()- Specified by:
nullAddin interfaceXAddingCollection<E>
-
add
Description copied from interface:XAddingCollectionAdds the passed element.- Specified by:
addin interfaceXAddingCollection<E>- Parameters:
e- to add- Returns:
trueif element was added;falseif not
-
addAll
- Specified by:
addAllin interfaceXAddingCollection<E>
-
addAll
- Specified by:
addAllin interfaceXAddingCollection<E>
-
addAll
- Specified by:
addAllin interfaceXAddingCollection<E>
-
accept
-
ensureFreeCapacity
Description copied from interface:CapacityExtendableEnsures 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:
ensureFreeCapacityin interfaceCapacityExtendable
-
ensureCapacity
- Specified by:
ensureCapacityin interfaceCapacityExtendable
-
currentCapacity
public final long currentCapacity()Description copied from interface:CapacityExtendableReturns 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:
currentCapacityin interfaceCapacityExtendable- Returns:
- the current capacity of this instance before a rebuild is required.
-
maximumCapacity
public final long maximumCapacity()Description copied from interface:CapacityCarryingReturns 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:
maximumCapacityin interfaceCapacityCarrying- Returns:
- the maximum amount of elements this carrier instance can contain.
-
isFull
public final boolean isFull()Description copied from interface:CapacityCarryingReturns true if the current capacity cannot be increased any more.- Specified by:
isFullin interfaceCapacityCarrying
-
remainingCapacity
public final long remainingCapacity()Description copied from interface:CapacityCarryingReturns the amount of elements this carrier instance can collect before reaching its maximimum capacity.- Specified by:
remainingCapacityin interfaceCapacityCarrying
-
optimize
public final long optimize()Description copied from interface:OptimizableCollectionOptimizes the internal storage of this collection and returns the storage size of the collection after the process is complete.- Specified by:
optimizein interfaceOptimizableCollection- Returns:
- the storage size of the collection after the optimzation.
-
hasVolatileElements
public final boolean hasVolatileElements()Description copied from interface:ExtendedCollectionTells if this collection contains volatile elements.
An element is volatile, if it can become no longer reachable by the collection without being removed from the collection. Examples areWeakReferenceofSoftReferenceor implementations of collection entries that remove the element contained in an entry by some means outside the collection.
Note thatWeakReferenceinstances that are added to a a simple (non-volatile) implementation of a collection do not make the collection volatile, as the elements themselves (the reference instances) are still strongly referenced.- Specified by:
hasVolatileElementsin interfaceExtendedCollection<E>- Returns:
trueif the collection contains volatile elements.
-
nullAllowed
public final boolean nullAllowed()Description copied from interface:ExtendedCollectionDefines if null-elements are allowed inside the collection or not.- Specified by:
nullAllowedin interfaceExtendedCollection<E>- Returns:
trueif null is allowed inside the collection;falseif not
-
isEmpty
- Specified by:
isEmptyin interfaceSized- Throws:
UnsupportedOperationException
-
size
- Specified by:
sizein interfaceSized- Throws:
UnsupportedOperationException
-