GenericTimeSeries implements Function<T, V>, Iterable<Pair<T, V>> { public boolean sameLeg(T a, T b) { if (cmp.compare(a, b) > 0) { throw new IllegalArgumentException(); } int i = binarySearch(times, a, cmp); i = (0 <= i) ? i : -i - 2; int j = binarySearch(times, b, cmp); int j1 = (0 <= j) ? j : -j - 2; return i == j1 || (j >= 0 && i + 1 == j); } GenericTimeSeries(Iterator<Pair<T, V>> timestamps);  GenericTimeSeries(Iterable<Pair<T, V>> timestamps);  GenericTimeSeries(Iterator<T> t, Function<T, V> f); static GenericTimeSeries<T, List<V>> merge(Iterable<GenericTimeSeries<T, V>> ts); static GenericTimeSeries<T, V> merge(Iterable<GenericTimeSeries<T, V>> ts, BinaryOperator<V> op); static GenericTimeSeries<T, U> merge(GenericTimeSeries<T, V> tv, GenericTimeSeries<T, V> tw, BiFunction<V, V, U> f); int size(); Pair<T, V> get(int i); GenericTimeSeries<T, V> relocate(Iterator<T> t); V apply(T x); boolean sameLeg(T a, T b); GenericTimeSeries<T, V> subSeries(T a, T b); Iterator<Pair<T, V>> iterator(); void addAttribute(String attribute, Object value); Object getAttribute(String attribute); Iterator<Map.Entry<String, Object>> getAttributes(); @Override boolean equals(Object x); @Override int hashCode();  }
@Test public void testSameLeg() { Iterator<Pair<Integer, Integer>> ps = of( pairOf((Integer) null, (Integer) null), pairOf(50, 6), pairOf(150, 12), pairOf(220, 24)); GenericTimeSeries<Integer, Integer> tv = new GenericTimeSeries<>(ps); assertTrue(tv.sameLeg(null, 0)); assertTrue(tv.sameLeg(0, 49)); assertTrue(tv.sameLeg(0, 50)); assertFalse(tv.sameLeg(0, 51)); assertTrue(tv.sameLeg(50, 150)); assertFalse(tv.sameLeg(0, 150)); assertTrue(tv.sameLeg(220, 10000)); }