Data structures that can map a range of keys to a value

后端 未结 7 2046
死守一世寂寞
死守一世寂寞 2020-11-27 18:02

I am trying to find a data structure that takes in a particular value from a range of values and map it to a key.

For example, I have the following conditions:

7条回答
  •  忘掉有多难
    2020-11-27 18:33

    This type of data structure is called an Interval Tree. (The Wikipedia page only presents the case where intervals may overlap, but one can imagine a case where you want to remove mappings for any overlapped intervals when you add a new interval. Do a Google search for implementations and see if any fit your needs.

提交回复
热议问题