Package uk.ac.manchester.spinnaker.utils
Class ValueHolder<T>
java.lang.Object
uk.ac.manchester.spinnaker.utils.ValueHolder<T>
- Type Parameters:
T
- The type of value to hold.
A simple class that can optionally hold a single value. This class is
modifiable.
- Author:
- Donal Fellows
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ValueHolder
public ValueHolder()Create an instance. The initial value held isnull
. -
ValueHolder
Create an instance.- Parameters:
value
- The initial value to hold.
-
-
Method Details
-
getValue
Get the value held.- Returns:
- The value held.
-
setValue
Set the value to hold.- Parameters:
value
- The new value to hold.
-
update
Applies a function to update the value of this instance, returning the old value.- Parameters:
function
- The operation to apply.- Returns:
- The old value.
-