Answer the question
In order to leave comments, you need to log in
What data structure to choose?
Hello.
There is a set of non-overlapping intervals (hereinafter referred to as layers) to which the textures correspond. The drawing function receives some interval that needs to be drawn. Thus, you need to find all the intersections of the given interval with each layer and draw each intersection with your own texture. Example:
Слои:
0.00 10.00 white
10.00 20.00 blue
20.00 30.00 red
Нужно отрисовать интервал: 5.00 45.00
В результате:
5.00 до 10.00 белым цветом
10.00 до 20.00 синим цветом
20.00 до 30.00 красным цветом
30.00 45.00 дефолтным цветом
Answer the question
In order to leave comments, you need to log in
if you have a search for the first interval, something like a binary search, then you can already well not fool your head further and yes there is such a structure here
en.m.wikipedia.org/wiki/Interval_tree
If there are several thousand intervals in total, then you will be surprised but naive O (n ) search will be faster than any tree structures.
(processor architecture features)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question