Пример #1
0
        static void RebuildUnderNodeWithoutLeaf(IntervalNode <TData> nodeForRebuild, IntervalNode <TData> leaf)
        {
            Debug.Assert(leaf.IsLeaf);
            Debug.Assert(!nodeForRebuild.IsLeaf);
            var newNode =
                IntervalNode <TData> .CreateIntervalNodeOnEnumeration(
                    nodeForRebuild.GetAllLeafNodes().Where(n => !(n.Equals(leaf))));

            nodeForRebuild.Count    = newNode.Count;
            nodeForRebuild.Left     = newNode.Left;
            nodeForRebuild.Right    = newNode.Right;
            nodeForRebuild.Interval = new Interval(newNode.Left.interval, newNode.Right.interval);
        }
Пример #2
0
 internal void Add(IntervalNode <TData> node)
 {
     if (rootNode == null)
     {
         rootNode = node;
     }
     else if (Count <= 2)
     {
         rootNode = IntervalNode <TData> .CreateIntervalNodeOnEnumeration(rootNode.GetAllLeafNodes().Concat(new[] { node }));
     }
     else
     {
         AddNodeToTreeRecursive(node, rootNode);
     }
 }
Пример #3
0
 /// <summary>
 /// rebuild the whole tree
 /// </summary>
 public void Rebuild()
 {
     rootNode = IntervalNode <TData> .CreateIntervalNodeOnEnumeration(rootNode.GetAllLeafNodes());
 }
Пример #4
0
 public IntervalRTree(IEnumerable <KeyValuePair <Interval, TData> > rectsAndData)
 {
     rootNode = IntervalNode <TData> .CreateIntervalNodeOnEnumeration(GetNodeRects(rectsAndData));
 }