This code has been rewritten as part of a broader collections library, source control has been migrated to git, and the new project is now hosted on

Project Description
This specialized generic collection provides fast, efficient retrieval of values which are associated to intervals rather than keys.

- Efficient O(log n) retrieval (self-balanced AVL-tree architecture)
- Retrieve values via interval or key within an interval
- Generic interval bounds support any comparable and equatable type
- Similar interface to IDictionary<> for low barrier to entry

Download Konves.Collections.IntervalDictionary from CodePlex or install using NuGet.

IntervalDictionary<int, string> months = new IntervalDictionary<int, string>();

// Add the month's first and last day-of-year values as the interval bounds and the month name as the value
months.Add(1, 31, "January");
months.Add(32, 59, "February");
months.Add(60, 90, "March");
months.Add(91, 120, "April");
months.Add(121, 151, "May");
months.Add(152, 181, "June");
months.Add(182, 212, "July");
months.Add(213, 243, "August");
months.Add(244, 273, "September");
months.Add(274, 304, "October");
months.Add(305, 334, "November");
months.Add(335, 365, "December");

// Gets the name of the month which is associated with the 264th day of the year
string month = months[264];

Outstanding Development
- Need to implement element removal
- Need to add unit tests

Last edited Jun 17, 2014 at 7:42 AM by skonves, version 8