Ejemplo n.º 1
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.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        public void Insert(Node node)
        {
            Assert.IsTrue(interval == null || interval.Contains(node.Interval));
            int index = GetSubnodeIndex(node.interval, centre);

            if (node.level == level - 1)
            {
                subnode[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);
                subnode[index] = childNode;
            }
        }