예제 #1
0
파일: Node.cs 프로젝트: AlvaIce/GFJT-2020
        /// <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);
        }
예제 #2
0
파일: Node.cs 프로젝트: AlvaIce/GFJT-2020
        /// <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;
            }
        }