Package jromp.var
Class ReductionVariable<T extends Serializable>
java.lang.Object
jromp.var.ReductionVariable<T>
- Type Parameters:
T
- the type of the variable.
- All Implemented Interfaces:
Serializable
,Variable<T>
Represents a reduction variable that its value is reduced from "custom" thread-local
variables using a reduction operation.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionReductionVariable
(ReductionOperation<T> operation, T initialValue) Constructs a new reduction variable with the given reduction operation and initial value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
end()
Performs any cleanup operations that may be required by the variable.boolean
isMerged()
Indicates whether the reduction variable has been merged.void
merge()
Merges the private variables of the threads to the result of the reduction operation.void
Sets the value of the variable.toString()
void
update
(UnaryOperator<T> operator) Applies the givenUnaryOperator
to update the value of the variable.value()
Retrieves the value of the variable.
-
Constructor Details
-
ReductionVariable
Constructs a new reduction variable with the given reduction operation and initial value.Note: The value of the "private" variables is initialized to the default initial value of the reduction variable.
- Parameters:
operation
- the reduction operation.initialValue
- the initial value of the reduction variable.
-
-
Method Details
-
value
Description copied from interface:Variable
Retrieves the value of the variable.- Specified by:
value
in interfaceVariable<T extends Serializable>
- Returns:
- the value of the variable.
-
set
Description copied from interface:Variable
Sets the value of the variable.- Specified by:
set
in interfaceVariable<T extends Serializable>
- Parameters:
value
- the new value to be set.
-
update
Description copied from interface:Variable
Applies the givenUnaryOperator
to update the value of the variable.- Specified by:
update
in interfaceVariable<T extends Serializable>
- Parameters:
operator
- the unary operator to apply.
-
end
public void end()Description copied from interface:Variable
Performs any cleanup operations that may be required by the variable.- Specified by:
end
in interfaceVariable<T extends Serializable>
-
isMerged
public boolean isMerged()Indicates whether the reduction variable has been merged.- Returns:
true
if the reduction variable has been merged;false
otherwise.
-
merge
public void merge()Merges the private variables of the threads to the result of the reduction operation. -
toString
-