Package uk.ac.starlink.util
Class ValueWatcher
java.lang.Object
uk.ac.starlink.util.ValueWatcher
Looks out for an unused value in a sequence of submitted numbers.
This can be used to identify a suitable 'magic' representation
for a bad value.
- Since:
- 22 Jun 2006
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionValueWatcher
(long loBound, long hiBound) Constructs a ValueWatcher which will look out for values in the range covered byloBound
andhiBound
inclusive. -
Method Summary
Modifier and TypeMethodDescriptionReturns a value in the rangeloBound..hiBound
which has never been sumitted touseValue(long)
.void
useValue
(long val) Takes note of a value.
-
Constructor Details
-
ValueWatcher
public ValueWatcher(long loBound, long hiBound) Constructs a ValueWatcher which will look out for values in the range covered byloBound
andhiBound
inclusive. These shouldn't be arbitrarily far apart - storage of up to about one bit per value in the range will be required.- Parameters:
loBound
- lower bound to watch for (inclusive)hiBound
- upper bound to watch for (inclusive)
-
-
Method Details
-
useValue
public void useValue(long val) Takes note of a value.val
will never subsequently be returned fromgetUnused()
.- Parameters:
val
- value to note
-
getUnused
Returns a value in the rangeloBound..hiBound
which has never been sumitted touseValue(long)
. If there is no such value, returns null.- Returns:
- unused value in range
-