]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/IntegerRange.java
Version 19, May 2018
[GpsPrune.git] / tim / prune / data / IntegerRange.java
index b11ba0e5b4993b9b53c39c40e1351dcf2aa1be82..d2424d1bcf557c272de9d1b850b2b301573c6b22 100644 (file)
@@ -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,32 +17,32 @@ 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 positive data values were found
+        * @return true if any values added to the range
         */
-       public boolean hasData()
-       {
-               return (_max >= 0);
+       public boolean hasValues() {
+               return _foundValues;
        }
 
-
        /**
         * @return minimum value, or -1 if none found
         */