Thursday, June 16

Interval Tree C# implementation

Today I'm happy to publish my Interval Tree C# implementation in CodePlex community code site.
I need to store lots of temporal data in a project I'm working on and to retrieve the data very very fast. After some search on the web I've found article in Wikipedia about Interval Tree which explain the data structure but did not direct me to any implementation of it.
I've also found a C# implementation of Multi-Dimensional Range Search Tree which is very useful for selecting points on two dimensions but did not solve the problem I need.

Finally I've found a Java implementation of Interval Tree which is just the thing I needed. Convert the Java code into C# was no brainer.

I've add some abilities to the implementation like using generics for both temporal value and user data type so you can create interval tree that use int, float, DateTime or even Vector as measure unit. Any struct that implementation IComparable will work just fine.

Also I've add the ability to stub the interval tree in different modes like all interval that contains the point, or contains or exactly at the start. This was important to me to be able to get information out of the interval tree for the actual project.

Like the guy who publish the Java implementation said I need that data structure and I'm publish it to help anyone else need of it.

Hope it will be useful to you as it is to me.

No comments:

Post a Comment