How to find point between two keys in sorted dictionary

后端 未结 5 1146
生来不讨喜
生来不讨喜 2021-01-22 23:43

I have a sorted dictionary that contains measured data points as key/value pairs. To determine the value for a non-measured data point I want to extrapolate the value between t

5条回答
  •  感情败类
    2021-01-23 00:21

    I don't think there is a function on SortedDictionary that lets you find elements around the one you need faster than iterating elements. (+1 to BrokenGlass solution)

    To be able to find items faster you need to switch to some other structure. I.e. SortedList provides similar functionality but allows to index its Key collection and hence you can use binary serach to find the range.

提交回复
热议问题