I’m looking for a data structure which can do search on a specific key. The key is an interval. Once a single value is passed to this structure it should find the correct interval (appropriate key) then this key may point to several other values.
I searched for some key to multiple values and found something like this:
Dictionary<double,LinkedList<T>>
But the key value here is a simple double and is not interval type. And if it was interval type, I must pass the interval as the key. However I need to search based on a single value and find the interval.
In other word, can we have a dictionary-like structure with a custom search behavior? (for example pass the search as an Func<,> parameter.)
I don’t know an existing structure like this. But there are a lot of ways to solve this problem yourself. First thing that comes to mind is to write an extension method for dictionary, like this: