TimestampMap implements TimeMap<Double, T> { protected int[] getOverlappingTimestamps(double intervalStart, double intervalEnd) { int index = Arrays.binarySearch(array, 0, size, intervalStart); index = index >= 0 ? index : (-index - 1); if (index < size) { int[] res = new int[size - index]; int i = 0; for (; index < size && array[index] <= intervalEnd; index++) { res[i++] = index; } if (res.length != i) { return Arrays.copyOf(res, i); } return res; } return new int[0]; } TimestampMap();  TimestampMap(int capacity); protected  TimestampMap(double[] keys); @Override boolean put(Double timestamp, T value); @Override boolean remove(Double timestamp); @Override T get(Double timestamp, T defaultValue); @Override Object get(Interval interval, Estimator estimator); @Override T[] toValuesArray(); @Override abstract Class<T> getTypeClass(); @Override abstract boolean isSupported(Estimator estimator); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Double timestamp); double[] getTimestamps(); @Override Double[] toKeysArray(); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object obj); String toString(TimeFormat timeFormat, DateTimeZone timeZone); String toString(TimeFormat timeFormat); @Override String toString();  }
@Test public void testGetOverlappingTimestamps() { TimestampIntegerMap i = new TimestampIntegerMap(); i.put(2001.0, 42); Assert.assertEquals(i.getOverlappingTimestamps(2001, 2002), new int[] { 0 }); Assert.assertEquals(i.getOverlappingTimestamps(2000, 2001), new int[] { 0 }); Assert.assertEquals(i.getOverlappingTimestamps(2000, Double.POSITIVE_INFINITY), new int[] { 0 }); TimestampIntegerMap j = new TimestampIntegerMap(); j.put(2001.0, 42); j.put(2002.0, 42); j.put(2004.0, 42); j.put(2005.0, 42); Assert.assertEquals(j.getOverlappingTimestamps(1998, 1999), new int[] {}); Assert.assertEquals(j.getOverlappingTimestamps(1998, 2001), new int[] { 0 }); Assert.assertEquals(j.getOverlappingTimestamps(1998, 2001.5), new int[] { 0 }); Assert.assertEquals(j.getOverlappingTimestamps(1998, 2002), new int[] { 0, 1 }); Assert.assertEquals(j.getOverlappingTimestamps(2001, 2001), new int[] { 0 }); Assert.assertEquals(j.getOverlappingTimestamps(2001, 2002), new int[] { 0, 1 }); Assert.assertEquals(j.getOverlappingTimestamps(2003, 2005), new int[] { 2, 3 }); Assert.assertEquals(j.getOverlappingTimestamps(2005, 2005), new int[] { 3 }); Assert.assertEquals(j.getOverlappingTimestamps(2005, 2016), new int[] { 3 }); Assert.assertEquals(j.getOverlappingTimestamps(2006, 2007), new int[] {}); }