X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fdata%2FIntegerRange.java;fp=src%2Ftim%2Fprune%2Fdata%2FIntegerRange.java;h=d2424d1bcf557c272de9d1b850b2b301573c6b22;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/data/IntegerRange.java b/src/tim/prune/data/IntegerRange.java new file mode 100644 index 0000000..d2424d1 --- /dev/null +++ b/src/tim/prune/data/IntegerRange.java @@ -0,0 +1,62 @@ +package tim.prune.data; + +/** + * Represents a range of integers, holding the maximum and + * minimum values. + */ +public class IntegerRange +{ + private int _min = -1, _max = -1; + private boolean _foundValues = false; + + + /** + * Clear for a new range calculation + */ + public void clear() + { + _min = -1; + _max = -1; + _foundValues = false; + } + + + /** + * Add a value to the range + * @param inValue value to add + */ + public void addValue(int inValue) + { + if (inValue < _min || !_foundValues) { + _min = inValue; + } + if (inValue > _max || !_foundValues) { + _max = inValue; + } + _foundValues = true; + } + + /** + * @return true if any values added to the range + */ + public boolean hasValues() { + return _foundValues; + } + + /** + * @return minimum value, or -1 if none found + */ + public int getMinimum() + { + return _min; + } + + + /** + * @return maximum value, or -1 if none found + */ + public int getMaximum() + { + return _max; + } +}