/// <summary> /// Performans a "stab" query with a single value. /// All items with overlapping ranges are returned. /// </summary> public List <T> Query(TKey value) { var results = new List <T>(); // If the node has items, check their ranges. if (_items != null) { foreach (var o in _items) { if (o.Range.From.CompareTo(value) > 0) { break; } else if (o.Range.Contains(value)) { results.Add(o); } } } // go to the left or go to the right of the tree, depending // where the query value lies compared to the center if (value.CompareTo(_center) < 0 && _leftNode != null) { results.AddRange(_leftNode.Query(value)); } else if (value.CompareTo(_center) > 0 && _rightNode != null) { results.AddRange(_rightNode.Query(value)); } return(results); }
/// <summary> /// Performans a "stab" query with a single value. /// All items with overlapping ranges are returned. /// </summary> public List <T> Query(TKey value) { if (!_isInSync && _autoRebuild) { Rebuild(); } return(_root.Query(value)); }