private List <double> FilterData(List <double> data, TimeRange timeRange, FilterMode filterMode) { if (data == null) { return(null); } var startIndex = BinarySearcher.GetFirstIndexEqualOrGreaterTimestampBinary(data, timeRange.Min); var endIndex = BinarySearcher.GetFirstIndexEqualOrGreaterTimestampBinary(data, timeRange.Max); if (endIndex == null) { endIndex = data.Count; } else if (timeRange.Insersects((long)data[endIndex.Value])) { endIndex += 2; } if (startIndex == null) { startIndex = 0; } else if (filterMode == FilterMode.MaxInclusive && timeRange.EqualsMin(data[startIndex.Value])) { startIndex += 2; } return(data.Skip(startIndex.Value).Take(endIndex.Value - startIndex.Value).ToList()); }