예제 #1
0
        /// <summary>
        /// Perform an interval intersection Query on the node
        /// </summary>
        /// <param name="target">the interval to intersect</param>
        /// <returns>all stubedIntervals containing time</returns>
        public List <T> Query(Interval <D> target)
        {
            List <T> result = new List <T>();

            if (totalInterval != null && totalInterval.Intersects(target))
            {
                foreach (var entry in intervals)
                {
                    if (entry.Key.Intersects(target))
                    {
                        result.AddRange(entry.Value);
                    }
                }
            }

            if (target.Start.CompareTo(center) < 0 && leftNode != null)
            {
                result.AddRange(leftNode.Query(target));
            }
            if (target.End.CompareTo(center) > 0 && rightNode != null)
            {
                result.AddRange(rightNode.Query(target));
            }
            return(result);
        }
예제 #2
0
 /// <summary>
 /// Perform an interval Query, returning the associated data.
 /// Will rebuild the tree if out of sync.
 /// </summary>
 /// <param name="start">the start of the interval to check</param>
 /// <param name="end">end of the interval to check</param>
 /// <returns>the data associated with all stubedIntervals that intersect target</returns>
 public List <T> Get(D start, D end)
 {
     Build();
     return(head.Query(new Interval <D>(start, end)));
 }