X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FIntegerRange.java;fp=tim%2Fprune%2Fdata%2FIntegerRange.java;h=d2424d1bcf557c272de9d1b850b2b301573c6b22;hp=a16f44badb2aec77f10061970e8851de47509cba;hb=92dad5df664287acb51728e9ea599f150765d34a;hpb=81843c3d8d0771bf00d0f26034a13aa515465c78 diff --git a/tim/prune/data/IntegerRange.java b/tim/prune/data/IntegerRange.java index a16f44b..d2424d1 100644 --- a/tim/prune/data/IntegerRange.java +++ b/tim/prune/data/IntegerRange.java @@ -2,11 +2,12 @@ package tim.prune.data; /** * Represents a range of integers, holding the maximum and - * minimum values. Values assumed to be >= 0. + * minimum values. */ public class IntegerRange { private int _min = -1, _max = -1; + private boolean _foundValues = false; /** @@ -16,22 +17,31 @@ public class IntegerRange { _min = -1; _max = -1; + _foundValues = false; } /** * Add a value to the range - * @param inValue value to add, only positive values considered + * @param inValue value to add */ public void addValue(int inValue) { - if (inValue >= 0) - { - if (inValue < _min || _min < 0) _min = inValue; - if (inValue > _max) _max = 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