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 TypeMethodDescriptionvoidend()Performs any cleanup operations that may be required by the variable.booleanisMerged()Indicates whether the reduction variable has been merged.voidmerge()Merges the private variables of the threads to the result of the reduction operation.voidSets the value of the variable.toString()voidupdate(UnaryOperator<T> operator) Applies the givenUnaryOperatorto 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:VariableRetrieves the value of the variable.- Specified by:
valuein interfaceVariable<T extends Serializable>- Returns:
- the value of the variable.
-
set
Description copied from interface:VariableSets the value of the variable.- Specified by:
setin interfaceVariable<T extends Serializable>- Parameters:
value- the new value to be set.
-
update
Description copied from interface:VariableApplies the givenUnaryOperatorto update the value of the variable.- Specified by:
updatein interfaceVariable<T extends Serializable>- Parameters:
operator- the unary operator to apply.
-
end
public void end()Description copied from interface:VariablePerforms any cleanup operations that may be required by the variable.- Specified by:
endin interfaceVariable<T extends Serializable>
-
isMerged
public boolean isMerged()Indicates whether the reduction variable has been merged.- Returns:
trueif the reduction variable has been merged;falseotherwise.
-
merge
public void merge()Merges the private variables of the threads to the result of the reduction operation. -
toString
-