Skip to content

Commit

Permalink
Method for retrieving LsfIterator's current index in the file.
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinto committed Dec 17, 2013
1 parent fca6b33 commit 96d3e15
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/pt/lsts/imc/lsf/LsfIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public class LsfIterator<T> implements Iterator<T>, Iterable<T>{
protected LsfIndex index;
protected double secondsBetweenMessages;
protected LinkedHashMap<Integer, Double> entityTimeStamps = new LinkedHashMap<Integer, Double>();
protected int curIndex;

public LsfIterator(LsfIndex index, Class<T> clazz, int fromIndex, long millisBetweenMessages) {
this.index = index;
this.index = index;
this.clazz = clazz;
this.secondsBetweenMessages = millisBetweenMessages / 1000.0;
this.msgName = clazz.getSimpleName();
this.nextIndex = index.getNextMessageOfType(msgName, fromIndex);
this.curIndex = fromIndex;
}

public LsfIterator(LsfIndex index, Class<T> clazz, long millisBetweenMessages) {
Expand All @@ -82,7 +84,7 @@ public T next() {
return null;
try {
T o = index.getMessage(nextIndex, clazz);

curIndex = nextIndex;
if (secondsBetweenMessages == 0) {
nextIndex = index.getNextMessageOfType(msgName, nextIndex);
}
Expand Down Expand Up @@ -116,7 +118,11 @@ public void remove() {
throw new UnsupportedOperationException();
}

public static void main(String[] args) throws Exception {
public int getCurrentIndex() {
return curIndex;
}

public static void main(String[] args) throws Exception {
LsfIndex index = new LsfIndex(new File("/home/zp/Desktop/log-imc5/Data.lsf"),
IMCDefinition.getInstance());

Expand Down

0 comments on commit 96d3e15

Please sign in to comment.