Ejemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="itemInterval"></param>
 /// <returns></returns>
 public static Node CreateNode(Interval itemInterval)
 {
     Key key = new Key(itemInterval);
 
     Node node = new Node(key.Interval, key.Level);
     return node;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 /// <param name="addInterval"></param>
 /// <returns></returns>
 public static Node CreateExpanded(Node node, Interval addInterval)
 {
     Interval expandInt = new Interval(addInterval);
     if (node != null) expandInt.ExpandToInclude(node.interval);
     Node largerNode = CreateNode(expandInt);
     if (node != null) largerNode.Insert(node);
     return largerNode;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        private Node CreateSubnode(int index)
        {   
            // create a new subnode in the appropriate interval
            double min = 0.0;
            double max = 0.0;

            switch (index) 
            {
                case 0:
                    min = interval.Min;
                    max = centre;
                    break;
                case 1:
                    min = centre;
                    max = interval.Max;
                    break;
                default:
			        break;
            }
            Interval subInt = new Interval(min, max);
            Node node = new Node(subInt, level - 1);
            return node;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public virtual void Insert(Node node)
 {
     Assert.IsTrue(interval == null || interval.Contains(node.Interval));
     int index = GetSubnodeIndex(node.interval, centre);
     if (node.level == level - 1) 
         Nodes[index] = node;            
     else 
     {
         // the node is not a direct child, so make a new child node to contain it
         // and recursively insert the node
         Node childNode = CreateSubnode(index);
         childNode.Insert(node);
         Nodes[index] = childNode;
     }
 }