SCViewer/plugins/com.minres.scviewer.database/src/com/minres/scviewer/database/EventEntry.java

42 lines
797 B
Java
Raw Normal View History

2021-02-27 13:26:07 +01:00
package com.minres.scviewer.database;
2021-02-27 14:47:37 +01:00
import java.util.Arrays;
2021-02-27 13:26:07 +01:00
public class EventEntry implements Comparable<EventEntry>{
public long timestamp; // unsigned
public IEvent[] events = null;
public EventEntry(long timestamp) {
this.timestamp = timestamp;
}
public EventEntry(long timestamp, IEvent[] events) {
this.timestamp = timestamp;
this.events = events;
}
@Override
public int compareTo(EventEntry o) {
return Long.compareUnsigned(timestamp, o.timestamp);
}
@Override
public String toString() {
return String.format("e.%d@%d", events.length,timestamp);
}
2021-02-27 14:47:37 +01:00
public void append(IEvent value) {
if(events.length==0)
events = new IEvent[] {value};
else {
int idx = events.length;
events = Arrays.copyOf(events, idx+1);
events[idx]=value;
}
}
2021-02-27 13:26:07 +01:00
}