]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/data/IntegerRange.java
Version 1, September 2006
[GpsPrune.git] / tim / prune / data / IntegerRange.java
diff --git a/tim/prune/data/IntegerRange.java b/tim/prune/data/IntegerRange.java
new file mode 100644 (file)
index 0000000..61ae34c
--- /dev/null
@@ -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;
+       }
+}