Exemplo n.º 1
0
        public T Find(QuadNode <T> subroot, Point point)
        {
            if (subroot == null)
            {
                return(default(T));
            }

            if (!subroot.WithinBoundary(point))
            {
                return(default(T));
            }

            if (!subroot.CanSubdivide(Resolution))
            {
                return(subroot.Value);
            }

            var child = subroot.GetChild(point);

            if (child == null)
            {
                return(default(T));
            }

            return(Find(child, point));
        }
Exemplo n.º 2
0
        public bool Insert(QuadNode <T> subroot, Point point, T val)
        {
            if (subroot == null)
            {
                return(false);
            }

            if (!subroot.WithinBoundary(point))
            {
                return(false);
            }

            if (!subroot.CanSubdivide(Resolution))
            {
                // Add the node
                subroot.Value = val;
                return(true);
            }

            return(Insert(subroot.Insert(point), point, val));
        }