private static bool HasIntervalThatIsSubsetOfInterval( C5.TreeDictionary<ulong, ulong> regions, ulong regionStart, ulong regionEnd) { // Is there any region in whose [start, end] interval is a sub-interval of // [regionStart, regionEnd]? // TryWeakSuccessor gives us the first region whose start is >= regionStart, // but there could be more regions with start >= regionStart and end <= regionEnd. // Need to traverse successors until start > regionEnd, making containment impossible. C5.KeyValuePair<ulong, ulong> range; if (regions.TryWeakSuccessor(regionStart, out range)) { if (range.Key >= regionStart && range.Value <= regionEnd) return true; } while (regions.TrySuccessor(range.Key, out range)) { if (range.Key > regionEnd) break; if (range.Key >= regionStart && range.Value <= regionEnd) return true; } return false; }