Exemple #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 <Interval <T, D> > Query(Interval <T, D> target)
        {
            List <Interval <T, D> > result = new List <Interval <T, D> >();

            foreach (var entry in intervals)
            {
                if (entry.Key.Intersects(target))
                {
                    foreach (Interval <T, D> interval in entry.Value)
                    {
                        result.Add(interval);
                    }
                }
                else if (entry.Key.Start.CompareTo(target.End) > 0)
                {
                    break;
                }
            }

            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);
        }
 /// <summary>
 /// Perform an interval Query, returning the interval objects.
 /// Will rebuild the tree if out of sync
 /// </summary>
 /// <param name="start">the start of the interval to check</param>
 /// <param name="end">the end of the interval to check</param>
 /// <returns>all stubedIntervals that intersect target</returns>
 public List <Interval <T, D> > GetIntervals(D start, D end)
 {
     Build();
     return(head.Query(new Interval <T, D>(start, end, default(T))));
 }