存储范围的数据结构 [英] Data Structure for Storing Ranges
问题描述
数据结构应该存储几个可能重叠的可变长度范围一些连续的时间尺度。
-
例如,您可以添加范围
a:[0,3] ,b:[4,7],c:[0,9]
。 -
插入时间不一定要特别
检索将采用一个范围作为参数,并返回与该重复的集合中的所有范围范围,例如:
-
Get(1,2)
返回a和c。Get(6,7)
将返回b和c。Get(2,6)
将返回所有三个。 -
检索需要尽可能高效
您可以使用的一种数据结构是一维的<一个href =http://en.wikipedia.org/wiki/R-tree =nofollow noreferrer> R-tree 。这些设计旨在处理范围并提供有效的检索。您还将了解艾伦运营商;时间间隔之间还有十几个关系,而不仅仅是重叠。
SO还有其他一些问题影响到这一领域,包括:
I am wondering if anyone knows of a data structure which would efficiently handle the following situation:
The data structure should store several, possibly overlapping, variable length ranges on some continuous timescale.
For example, you might add the ranges
a:[0,3], b:[4,7], c:[0,9]
.Insertion time does not need to be particularly efficient.
Retrievals would take a range as a parameter, and return all the ranges in the set that overlap with the range, for example:
Get(1,2)
would return a and c.Get(6,7)
would return b and c.Get(2,6)
would return all three.Retrievals need to be as efficient as possible.
One data structure you could use is a one-dimensional R-tree. These are designed to deal with ranges and to provide efficient retrieval. You will also learn about Allen's Operators; there are a dozen other relationships between time intervals than just 'overlaps'.
There are other questions on SO that impinge on this area, including:
这篇关于存储范围的数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!