-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMinFilterN.java
More file actions
30 lines (28 loc) · 833 Bytes
/
Copy pathMinFilterN.java
File metadata and controls
30 lines (28 loc) · 833 Bytes
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
/**
* MinFilterN extends ComparableFilterN, setting the compare function
* such that if the current input is less than the previous (via
* compareTo() function), it returns true.
* @author gmh73
*
* @param <T>
*/
public class MinFilterN<T extends Comparable<T>> extends CompareFilterN<T> {
/**
* Builds a MinFilterN that remembers n inputs.
* @param n The number of inputs the filter will remember
*/
public MinFilterN(int n) {
super(n);
}
/**
* Returns true if left < right.
* In this case, a null value is interpreted as
* a max value, so if right is null and left is anything but null,
* true is returned.
* If left and right are both null, false is returned.
*/
@Override
public boolean compare(T left, T right) {
return right == null || (left != null && left.compareTo(right) <= 0);
}
}