File: IntegerRange.java

package info (click to toggle)
gpsprune 17-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,984 kB
  • ctags: 5,218
  • sloc: java: 39,403; sh: 25; makefile: 17; python: 15
file content (52 lines) | stat: -rw-r--r-- 782 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;


	/**
	 * Clear for a new range calculation
	 */
	public void clear()
	{
		_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 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;
	}
}