Ejemplo n.º 1
0
        public virtual bool Remove(ILeaf <T> leaf)
        {
            var success = false;

            if (leaf.IntersectionTest(Volume))
            {
                if (childNodes.Count > 0)
                {
                    foreach (var child in childNodes)
                    {
                        success |= child.Remove(leaf);
                    }
                    if (success)
                    {
                        LeafCount--;
                    }
                }
                else
                {
                    success   = leafs.Remove(leaf);
                    LeafCount = leafs.Count;
                }
            }

            return(success);
        }
Ejemplo n.º 2
0
        public virtual bool Add(ILeaf <T> leaf)
        {
            var success = false;

            if (leaf.IntersectionTest(Volume))
            {
                if (childNodes.Count > 0)
                {
                    success = AddToChildren(leaf);
                    if (success)
                    {
                        LeafCount++;
                    }
                }
                else
                {
                    success   = leafs.Add(leaf);
                    LeafCount = leafs.Count;

                    if (leafs.Count > maxLeafsPerNode && Level < maxDepth)
                    {
                        Extend();
                    }
                }
            }

            return(success);
        }