A dictionary object that uses ranges of values for keys

前端 未结 8 826
情深已故
情深已故 2020-11-27 19:26

I have need of a sort of specialized dictionary. My use case is this: The user wants to specify ranges of values (the range could be a single point as well) and assign a v

8条回答
  •  独厮守ぢ
    2020-11-27 20:13

    This is only going to work when the intervals don't overlap. And your main problem seems to be converting from a single (key) value to an interval.

    I would write a wrapper around SortedList. The SortedList.Keys.IndexOf() would find you an index that can be used to verify if the interval is valid and then use it.

提交回复
热议问题