Merge lp:~oontvoo/kalmanfilterimpl/point_comparable into lp:kalmanfilterimpl

Proposed by Vy Nguyen
Status: Merged
Approved by: Vy Nguyen
Approved revision: 3
Merged at revision: 3
Proposed branch: lp:~oontvoo/kalmanfilterimpl/point_comparable
Merge into: lp:kalmanfilterimpl
Diff against target: 39 lines (+10/-1)
1 file modified
src/kalmanfilter/RunFilter.java (+10/-1)
To merge this branch: bzr merge lp:~oontvoo/kalmanfilterimpl/point_comparable
Reviewer Review Type Date Requested Status
Vy Nguyen Pending
Review via email: mp+112463@code.launchpad.net

Description of the change

Make Point comparable to ensure the input Points are sorted in time order

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/kalmanfilter/RunFilter.java'
2--- src/kalmanfilter/RunFilter.java 2012-06-27 01:47:04 +0000
3+++ src/kalmanfilter/RunFilter.java 2012-06-28 00:23:18 +0000
4@@ -23,6 +23,7 @@
5 import Jama.Matrix;
6 import java.util.ArrayList;
7 import java.util.Arrays;
8+import java.util.Collections;
9 import java.util.List;
10
11 /**
12@@ -31,7 +32,7 @@
13 */
14 public class RunFilter
15 {
16- public static class Point
17+ public static class Point implements Comparable<Point>
18 {
19 final double x; // x coord
20 final double y; // y coord
21@@ -42,10 +43,18 @@
22 this.y = y;
23 this.t = t;
24 }
25+ @Override
26+ public int compareTo(Point o)
27+ {
28+ return Double.compare(t, o.t);
29+ }
30 }
31
32 public static List<Point> filter(List<Point> inputs, double sensorNoise)
33 {
34+ // sort the points in time order
35+ Collections.sort(inputs);
36+
37 List<Point> output = new ArrayList<>(inputs.size());
38
39 //(Matrix X, Matrix P, Matrix Q, Matrix H, Matrix A, Matrix R)

Subscribers

People subscribed via source and target branches

to all changes: