ArgumentChecker.isTrue(startTime < endTime, "Start time {} must be before end time {}", startTime, endTime);
final int n = allTimes.length;
if (n == 0) {
return new double[] {startTime, endTime };
}
final DoubleLinkedOpenHashSet truncated = new DoubleLinkedOpenHashSet(n + 2, 1);
for (final Double time : allTimes) {
if (time > startTime && time < endTime) {
truncated.add(time);
}
}
final int truncatedSize = truncated.size();
if (truncatedSize == 0) {
return new double[] {startTime, endTime };
}
final double[] truncatedArray = truncated.toDoubleArray();
if (!sorted) {
Arrays.sort(truncatedArray);
}
if (CompareUtils.closeEquals(truncatedArray[0], startTime, tolerance)) {
if (CompareUtils.closeEquals(truncatedArray[truncatedSize - 1], endTime, tolerance)) {