Finding temporary data
I am developing an application (in C #) where objects are active for a certain period of time, they have from and to properties of type DateTime. Now I want to speed up my search routine for queries such as: Are there other active objects at this time period / at this time.
Is there any existing temporary index that I can use or can I use QuadTree / other tree structures for efficient searches.
a source to share
You can also look at the tree :
In computer science, an interval tree is an ordered tree data structure for hold intervals. In particular, it allows you to efficiently find all intervals that intersect with any given interval or point.
And it reminds me of this SO question .
a source to share
This is an interesting sorting problem as you need to consider the start and end date of each item. If you used a simple sorting algorithm, then you can sort either the start date or the end date, but sorting by both will not be very efficient because an element with an early start date may have a very late end date, or an element with a late start date may have an early date. endings, which means you can't pre-sort this list based on the criteria "are any of these items active right now?"
If you are looking for a super efficient mechanism for doing this, I may not have an answer for you, but if you are just looking for something easy to do with existing C # data structures, I would consider creating two sorted lists, sorted by start date. and another sort by end date. Find a start date sorted list for items that start before this point, and search the date sorted list for items that end right now. Cross over these results to get the definitive answer.
As I said, I'm sure there is a better mechanism for this, but if I wanted to keep it simple and just use what I had, I would think about it.
a source to share