X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FIntegerRange.java;fp=tim%2Fprune%2Fdata%2FIntegerRange.java;h=61ae34c4ad58f7e9d61a4f320bc76181f43da3e7;hb=312fec956e43f5d0a38617da5d0add9c62563e2c;hp=0000000000000000000000000000000000000000;hpb=db1c1602b89209f4c92e8bd12ad38cd243fb27c7;p=GpsPrune.git diff --git a/tim/prune/data/IntegerRange.java b/tim/prune/data/IntegerRange.java new file mode 100644 index 0000000..61ae34c --- /dev/null +++ b/tim/prune/data/IntegerRange.java @@ -0,0 +1,51 @@ +package tim.prune.data; + +/** + * Represents a range of integers, holding the maximum and + * minimum values. Values assumed to be >= 0. + */ +public class IntegerRange +{ + private int _min = -1, _max = -1; + + + /** + * Add a value to the range + * @param inValue value to add, only positive values considered + */ + public void addValue(int inValue) + { + if (inValue >= 0) + { + if (inValue < _min || _min < 0) _min = inValue; + if (inValue > _max) _max = inValue; + } + } + + + /** + * @return true if positive data values were found + */ + public boolean hasData() + { + return (_max >= 0); + } + + + /** + * @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; + } +}