@Test public void getFirstContainingTime() throws Exception { GenericWindowing exp = new GenericWindowing(new ExponentialWindowLengths(2)); assertEquals(101, exp.getFirstContainingTime(98, 99, 100)); assertEquals(103, exp.getFirstContainingTime(96, 99, 100)); assertEquals(107, exp.getFirstContainingTime(92, 99, 100)); assertEquals(115, exp.getFirstContainingTime(84, 99, 100)); }
@Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } }
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } } }
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } } GenericWindowing(WindowLengthsSequence windowLengths); }
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(long N); }
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).getValue(); if (firstMarker >= l) { return firstMarker + Tr + 1; } else { addWindowsPastMarker(l); long currWindowL = windowStartMarkers.floor(l), currWindowR = windowStartMarkers.higher(l) - 1; if (r <= currWindowR) { return T; } else { assert currWindowR - currWindowL + 1 >= length; return currWindowR + Tr + 2; } } } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(long N);  }