private static void cleanUp(LongArray eventArray, long endTime) { int size = eventArray.size(); int indicesToRemove = 0; for (int i = 0; i < size; i++) { if (eventArray.get(i) < endTime) { indicesToRemove++; } } if (indicesToRemove > 0) { for (int i = 0; i < size - indicesToRemove; i++) { eventArray.set(i, eventArray.get(i + indicesToRemove)); } eventArray.dropTail(indicesToRemove); } }
private static boolean hasEventBetweenTimestamps( LongArray eventArray, long startTime, long endTime) { for (int i = 0; i < eventArray.size(); i++) { long time = eventArray.get(i); if (time >= startTime && time < endTime) { return true; } } return false; }
private static long getLastEventBetweenTimestamps( LongArray eventArray, long startTime, long endTime) { long lastEvent = -1; for (int i = 0; i < eventArray.size(); i++) { long time = eventArray.get(i); if (time >= startTime && time < endTime) { lastEvent = time; } else if (time >= endTime) { break; } } return lastEvent; }