Exemplo n.º 1
0
        /// <summary>
        /// Insert an item which is known to be contained in the tree rooted at the given Noed.
        /// Lower levels of the tree will be created it necessary to hold the item.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="itemInterval"></param>
        /// <param name="item"></param>
        private void InsertContained(Node tree, Interval itemInterval, object item)
        {
            Debug.Assert(tree.Interval.Contains(itemInterval));

            // Do NOT create a new node for zero-area intervals - this would lead
            // to infinite recursion. Instead, use a heuristic of simply returning
            // the smallest existing node containing the query
            bool     isZeroArea = IntervalSize.IsZeroWidth(itemInterval.Min, itemInterval.Max);
            NodeBase node;

            if (isZeroArea)
            {
                node = tree.Find(itemInterval);
            }
            else
            {
                node = tree.GetNode(itemInterval);
            }
            node.Add(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Insert an item which is known to be contained in the tree rooted at
        /// the given Node.  Lower levels of the tree will be created
        /// if necessary to hold the item.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="itemInterval"></param>
        /// <param name="item"></param>
        private static void InsertContained(Node <T> tree, Interval itemInterval, T item)
        {
            Assert.IsTrue(tree.Interval.Contains(itemInterval));

            /*
             * Do NOT create a new node for zero-area intervals - this would lead
             * to infinite recursion. Instead, use a heuristic of simply returning
             * the smallest existing node containing the query
             */
            bool         isZeroArea = IntervalSize.IsZeroWidth(itemInterval.Min, itemInterval.Max);
            NodeBase <T> node;

            if (isZeroArea)
            {
                node = tree.Find(itemInterval);
            }
            else
            {
                node = tree.GetNode(itemInterval);
            }
            node.Add(item);
        }