/// <summary> /// Performs a point query with a single value. /// All items with overlapping ranges are returned. /// </summary> public IEnumerable <TValue> Query(TKey value) { var results = new List <TValue>(); // If the node has items, check for leaves containing the value. if (items != null) { foreach (var o in items) { if (comparer.Compare(o.From, value) > 0) { break; } else if (comparer.Compare(value, o.From) >= 0 && comparer.Compare(value, o.To) <= 0) { results.Add(o.Value); } } } // go to the left or go to the right of the tree, depending // where the query value lies compared to the center var centerComp = comparer.Compare(value, center); if (leftNode != null && centerComp < 0) { results.AddRange(leftNode.Query(value)); } else if (rightNode != null && centerComp > 0) { results.AddRange(rightNode.Query(value)); } return(results); }
public IEnumerable <TValue> Query(TKey value) { if (!isInSync) { Rebuild(); } return(root.Query(value)); }