import java.util.HashMap;
import java.io.*;
-public class AltosRecord {
+public class AltosRecord implements Comparable <AltosRecord> {
final static int MISSING = 0x7fffffff;
static final int seen_flight = 1;
return null;
}
+ public int compareTo(AltosRecord o) {
+ return tick - o.tick;
+ }
+
public AltosRecord(AltosRecord old) {
version = old.version;
seen = old.seen;
import java.text.*;
public class AltosTelemetryIterable extends AltosRecordIterable {
- LinkedList<AltosRecord> records;
+ TreeSet<AltosRecord> records;
public Iterator<AltosRecord> iterator () {
return records.iterator();
int boost_tick = 0;
AltosRecord previous = null;
- records = new LinkedList<AltosRecord> ();
+ records = new TreeSet<AltosRecord> ();
try {
for (;;) {
if (records.isEmpty()) {
current_tick = record.tick;
} else {
- int tick = record.tick | (current_tick & ~ 0xffff);
- if (tick < current_tick - 0x1000)
+ int tick = record.tick;
+ while (tick < current_tick - 0x1000)
tick += 0x10000;
current_tick = tick;
record.tick = current_tick;
public AltosRecord update_state(AltosRecord previous) {
AltosRecord next;
- if (previous != null) {
+ if (previous != null)
next = new AltosRecord(previous);
- while (tick < previous.tick)
- tick += 65536;
- } else
+ else
next = new AltosRecord();
next.serial = serial;
next.tick = tick;