Exemple #1
0
        /// <summary>
        /// Perform a stabbing Query on the node
        /// </summary>
        /// <param name="time">the time to Query at</param>
        /// <returns>all stubedIntervals containing time</returns>
        public List <Interval <T, D> > Stab(D time, ContainConstrains constraint)
        {
            List <Interval <T, D> > result = new List <Interval <T, D> >();

            foreach (var entry in intervals)
            {
                if (entry.Key.Contains(time, constraint))
                {
                    foreach (var interval in entry.Value)
                    {
                        result.Add(interval);
                    }
                }
                else if (entry.Key.Start.CompareTo(time) > 0)
                {
                    break;
                }
            }

            if (time.CompareTo(center) < 0 && leftNode != null)
            {
                result.AddRange(leftNode.Stab(time, constraint));
            }
            else if (time.CompareTo(center) > 0 && rightNode != null)
            {
                result.AddRange(rightNode.Stab(time, constraint));
            }
            return(result);
        }
Exemple #2
0
        public bool Contains(D time, ContainConstrains constraint)
        {
            bool isContained;

            switch (constraint)
            {
            case ContainConstrains.None:
                isContained = Contains(time);
                break;

            case ContainConstrains.IncludeStart:
                isContained = ContainsWithStart(time);
                break;

            case ContainConstrains.IncludeEnd:
                isContained = ContainsWithEnd(time);
                break;

            case ContainConstrains.IncludeStartAndEnd:
                isContained = ContainsWithStartEnd(time);
                break;

            default:
                throw new ArgumentException("Ivnalid constraint " + constraint);
            }

            return(isContained);
        }
Exemple #3
0
        /// <summary>
        /// Perform a stabbing Query on the node
        /// </summary>
        /// <param name="time">the time to Query at</param>
        /// <returns>all stubedIntervals containing time</returns>
        public List <T> Stab(D time, ContainConstrains constraint)
        {
            List <T> result = new List <T>();

            if (totalInterval != null && totalInterval.Contains(time, constraint))
            {
                foreach (var entry in intervals)
                {
                    if (entry.Key.Contains(time, constraint))
                    {
                        result.AddRange(entry.Value);
                    }
                }
            }

            if (time.CompareTo(center) < 0 && leftNode != null)
            {
                result.AddRange(leftNode.Stab(time, constraint));
            }
            else if (time.CompareTo(center) > 0 && rightNode != null)
            {
                result.AddRange(rightNode.Stab(time, constraint));
            }
            return(result);
        }