private void EnsureIntervals()
 {
     if (this.intervals == null)
     {
         this.intervals = new IntervalCollection();
     }
 }
예제 #2
0
 internal bool MoveNext()
 {
     while (this.nextNode != null)
     {
         this.currentNode = this.nextNode;
         double num = this.currentNode.Value;
         if (this.val < num)
         {
             this.slot     = this.currentNode.LtSlot;
             this.nextNode = this.currentNode.Left;
         }
         else if (this.val > num)
         {
             this.slot     = this.currentNode.GtSlot;
             this.nextNode = this.currentNode.Right;
         }
         else
         {
             this.slot     = this.currentNode.EqSlot;
             this.nextNode = null;
         }
         if (this.slot != null)
         {
             return(true);
         }
     }
     return(false);
 }
 internal bool MoveNext()
 {
     while (this.nextNode != null)
     {
         this.currentNode = this.nextNode;
         double num = this.currentNode.Value;
         if (this.val < num)
         {
             this.slot = this.currentNode.LtSlot;
             this.nextNode = this.currentNode.Left;
         }
         else if (this.val > num)
         {
             this.slot = this.currentNode.GtSlot;
             this.nextNode = this.currentNode.Right;
         }
         else
         {
             this.slot = this.currentNode.EqSlot;
             this.nextNode = null;
         }
         if (this.slot != null)
         {
             return true;
         }
     }
     return false;
 }
예제 #4
0
 void EnsureIntervals()
 {
     if (null == this.intervals)
     {
         this.intervals = new IntervalCollection();
     }
 }
 internal IntervalTreeTraverser(double val, IntervalBoundary root)
 {
     this.currentNode = null;
     this.slot = null;
     this.nextNode = root;
     this.val = val;
 }
예제 #6
0
 internal IntervalTreeTraverser(double val, IntervalBoundary root)
 {
     this.currentNode = null;
     this.slot        = null;
     this.nextNode    = root;
     this.val         = val;
 }
예제 #7
0
        internal bool MoveNext()
        {
            while (null != this.nextNode)
            {
                this.currentNode = this.nextNode;
                double currentVal = this.currentNode.Value;
                if (val < currentVal)
                {
                    this.slot     = this.currentNode.LtSlot;
                    this.nextNode = this.currentNode.Left;
                }
                else if (val > currentVal)
                {
                    this.slot     = this.currentNode.GtSlot;
                    this.nextNode = this.currentNode.Right;
                }
                else
                {
                    this.slot     = this.currentNode.EqSlot;
                    this.nextNode = null;
                }
                if (null != this.slot)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #8
0
 void AddToSlot(ref IntervalCollection slot, Interval interval)
 {
     if (null == slot)
     {
         slot = new IntervalCollection();
     }
     slot.AddUnique(interval);
 }
예제 #9
0
 private void AddToSlot(ref IntervalCollection slot, Interval interval)
 {
     if (slot == null)
     {
         slot = new IntervalCollection();
     }
     slot.AddUnique(interval);
 }
 private void AddToSlot(ref IntervalCollection slot, Interval interval)
 {
     if (slot == null)
     {
         slot = new IntervalCollection();
     }
     slot.AddUnique(interval);
 }
예제 #11
0
        Interval GetIntervalFromSlot(IntervalCollection slot, double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
        {
            int index;

            if (null != slot && -1 != (index = slot.IndexOf(lowerBound, lowerOp, upperBound, upperOp)))
            {
                return(slot[index]);
            }
            return(null);
        }
예제 #12
0
        Interval GetIntervalFromSlot(IntervalCollection slot, object data)
        {
            int index;

            if (null != slot && -1 != (index = slot.IndexOf(data)))
            {
                return(slot[index]);
            }
            return(null);
        }
 private void RemoveFromSlot(ref IntervalCollection slot, Interval interval)
 {
     if (slot != null)
     {
         slot.Remove(interval);
         if (!slot.HasIntervals)
         {
             slot = null;
         }
     }
 }
예제 #14
0
 private void RemoveFromSlot(ref IntervalCollection slot, Interval interval)
 {
     if (slot != null)
     {
         slot.Remove(interval);
         if (!slot.HasIntervals)
         {
             slot = null;
         }
     }
 }
예제 #15
0
 void RemoveFromSlot(ref IntervalCollection slot, Interval interval)
 {
     if (null != slot)
     {
         slot.Remove(interval);
         if (!slot.HasIntervals)
         {
             slot = null;
         }
     }
 }
 internal IntervalCollection GetIntervalsWithEndPoint(double endPoint)
 {
     IntervalCollection intervals = new IntervalCollection();
     int count = this.Count;
     for (int i = 0; i < count; i++)
     {
         Interval interval = this[i];
         if (interval.HasMatchingEndPoint(endPoint))
         {
             intervals.Add(interval);
         }
     }
     return intervals;
 }
예제 #17
0
        void RemoveBoundary(IntervalBoundary boundary)
        {
            IntervalCollection replacementIntervals = null;
            int replacementCount = 0;

            if (null != boundary.Left && null != boundary.Right)
            {
                // Neither left/right are null. Typical binary tree node removal - replace the removed node
                // with the symmetric order predecessor
                IntervalBoundary replacement = boundary.Left;
                while (null != replacement.Right)
                {
                    replacement = replacement.Right;
                }
                // Find all intervals with endpoint y in the tree
                replacementIntervals = this.intervals.GetIntervalsWithEndPoint(replacement.Value);

                // Remove the intervals from the tree
                replacementCount = replacementIntervals.Count;
                for (int i = 0; i < replacementCount; ++i)
                {
                    this.RemoveIntervalFromTree(replacementIntervals[i]);
                }

                double val = boundary.Value;
                boundary.Value    = replacement.Value;
                replacement.Value = val;
                boundary          = replacement;
            }

            if (null != boundary.Left)
            {
                this.Replace(boundary, boundary.Left);
            }
            else
            {
                this.Replace(boundary, boundary.Right);
            }

            // Discard the node
            boundary.Parent = null;
            boundary.Left   = null;
            boundary.Right  = null;

            // Reinstall Intervals
            for (int i = 0; i < replacementCount; ++i)
            {
                this.AddIntervalToTree(replacementIntervals[i]);
            }
        }
        internal IntervalCollection GetIntervalsWithEndPoint(double endPoint)
        {
            IntervalCollection intervals = new IntervalCollection();
            int count = this.Count;

            for (int i = 0; i < count; i++)
            {
                Interval interval = this[i];
                if (interval.HasMatchingEndPoint(endPoint))
                {
                    intervals.Add(interval);
                }
            }
            return(intervals);
        }
예제 #19
0
        void Match(int valIndex, double point, QueryBranchResultSet results)
        {
            IntervalTreeTraverser traverser = new IntervalTreeTraverser(point, this.intervalTree.Root);

            while (traverser.MoveNext())
            {
                IntervalCollection matches = traverser.Slot;
                for (int i = 0, count = matches.Count; i < count; ++i)
                {
                    QueryBranch branch = matches[i].Branch;
                    if (null != branch)
                    {
                        results.Add(branch, valIndex);
                    }
                }
            }
        }
예제 #20
0
        private void Match(int valIndex, double point, QueryBranchResultSet results)
        {
            IntervalTreeTraverser traverser = new IntervalTreeTraverser(point, this.intervalTree.Root);

            while (traverser.MoveNext())
            {
                IntervalCollection slot = traverser.Slot;
                int num   = 0;
                int count = slot.Count;
                while (num < count)
                {
                    QueryBranch branch = slot[num].Branch;
                    if (branch != null)
                    {
                        results.Add(branch, valIndex);
                    }
                    num++;
                }
            }
        }
        private void RemoveBoundary(IntervalBoundary boundary)
        {
            IntervalCollection intervalsWithEndPoint = null;
            int count = 0;

            if ((boundary.Left != null) && (boundary.Right != null))
            {
                IntervalBoundary left = boundary.Left;
                while (left.Right != null)
                {
                    left = left.Right;
                }
                intervalsWithEndPoint = this.intervals.GetIntervalsWithEndPoint(left.Value);
                count = intervalsWithEndPoint.Count;
                for (int j = 0; j < count; j++)
                {
                    this.RemoveIntervalFromTree(intervalsWithEndPoint[j]);
                }
                double num3 = boundary.Value;
                boundary.Value = left.Value;
                left.Value     = num3;
                boundary       = left;
            }
            if (boundary.Left != null)
            {
                this.Replace(boundary, boundary.Left);
            }
            else
            {
                this.Replace(boundary, boundary.Right);
            }
            boundary.Parent = null;
            boundary.Left   = null;
            boundary.Right  = null;
            for (int i = 0; i < count; i++)
            {
                this.AddIntervalToTree(intervalsWithEndPoint[i]);
            }
        }
예제 #22
0
 void AddToSlot(ref IntervalCollection slot, Interval interval)
 {
     if (null == slot)
     {
         slot = new IntervalCollection();
     }
     slot.AddUnique(interval);
 }
 private void EnsureIntervals()
 {
     if (this.intervals == null)
     {
         this.intervals = new IntervalCollection();
     }
 }
예제 #24
0
 void EnsureIntervals()
 {
     if (null == this.intervals)
     {
         this.intervals = new IntervalCollection();
     }
 }
예제 #25
0
        internal bool MoveNext()
        {
            while (null != this.nextNode)
            {
                this.currentNode = this.nextNode;
                double currentVal = this.currentNode.Value;
                if (val < currentVal)
                {
                    this.slot = this.currentNode.LtSlot;
                    this.nextNode = this.currentNode.Left;
                }
                else if (val > currentVal)
                {
                    this.slot = this.currentNode.GtSlot;
                    this.nextNode = this.currentNode.Right;
                }
                else
                {
                    this.slot = this.currentNode.EqSlot;
                    this.nextNode = null;
                }
                if (null != this.slot)
                {
                    return true;
                }
            }

            return false;
        }
예제 #26
0
 void RemoveFromSlot(ref IntervalCollection slot, Interval interval)
 {
     if (null != slot)
     {
         slot.Remove(interval);
         if (!slot.HasIntervals)
         {
             slot = null;
         }
     }
 }
예제 #27
0
 Interval GetIntervalFromSlot(IntervalCollection slot, double lowerBound, IntervalOp lowerOp, double upperBound, IntervalOp upperOp)
 {
     int index;
     if (null != slot && -1 != (index = slot.IndexOf(lowerBound, lowerOp, upperBound, upperOp)))
     {
         return slot[index];
     }
     return null;
 }
예제 #28
0
 Interval GetIntervalFromSlot(IntervalCollection slot, object data)
 {
     int index;
     if (null != slot && -1 != (index = slot.IndexOf(data)))
     {
         return slot[index];
     }
     return null;
 }