예제 #1
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Pre order traverse of tree nodes.
         * CAUTION: If the tree is not memory resident, all nodes will be loaded
         * into main memory.
         *
         * @param root The node where the traversing should begin.
         * @return A ArrayList containing all tree nodes in the correct order.
         */
        public ArrayList TraversePreOrder(AbstractNode root)
        {
            if (root == null)
            {
                throw new ArgumentException("Node cannot be null.");
            }

            ArrayList v = new ArrayList();

            if (root.IsLeaf())
            {
                v.Add(root);
            }
            else
            {
                for (int i = 0; i < root.UsedSpace; i++)
                {
                    ArrayList a = TraversePreOrder(((Index)root).GetChild(i));
                    for (int j = 0; j < a.Count; j++)
                    {
                        v.Add(a[j]);
                    }
                }
                v.Add(root);
            }
            return(v);
        }
예제 #2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Returns a ArrayList with all Hypercubes that completely contain HyperCube
         * <B>h</B>.
         * The HyperCubes are returned in post order traversing, according to the
         * Nodes where they belong.
         *
         * @param h The given HyperCube.
         * @param root The node where the search should begin.
         * @return A ArrayList containing the appropriate HyperCubes in the correct
         * order.
         */
        public ArrayList Enclosure(HyperCube h, AbstractNode root)
        {
            if (h == null || root == null)
            {
                throw new
                      ArgumentException("Arguments cannot be null.");
            }

            if (h.GetDimension() != _file.Dimension)
            {
                throw new
                      ArgumentException("HyperCube dimension " +
                                        "different than RTree dimension.");
            }

            ArrayList v = new ArrayList();

            if (root.GetNodeMbb().Enclosure(h))
            {
                v.Add(root);

                if (!root.IsLeaf())
                {
                    for (int i = 0; i < root.UsedSpace; i++)
                    {
                        if (root.Data[i].Enclosure(h))
                        {
                            ArrayList a = Enclosure(h, ((Index)root).GetChild(i));
                            for (int j = 0; j < a.Count; j++)
                            {
                                v.Add(a[j]);
                            }
                        }
                    }
                }
            }
            return(v);
        }
예제 #3
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Pre order traverse of tree nodes.
         * CAUTION: If the tree is not memory resident, all nodes will be loaded
         * into main memory.
         *
         * @param root The node where the traversing should begin.
         * @return A ArrayList containing all tree nodes in the correct order.
         */
        public ArrayList TraversePreOrder(AbstractNode root)
        {
            if (root == null)
            {
                throw new ArgumentException("Node cannot be null.");
            }

            ArrayList v = new ArrayList();

            if (root.IsLeaf())
            {
                v.Add(root);
            }
            else
            {
                for (int i = 0; i < root.UsedSpace; i++)
                {
                    ArrayList a = TraversePreOrder(((Index)root).GetChild(i));
                    for (int j = 0; j < a.Count; j++)
                    {
                        v.Add(a[j]);
                    }
                }
                v.Add(root);
            }
            return v;
        }
예제 #4
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Returns a ArrayList with all nodes that Intersect with the given HyperCube.
         * The nodes are returned in post order traversing
         *
         * @param h The given HyperCube that is tested for overlapping.
         * @param root The node where the search should begin.
         * @return A ArrayList containing the appropriate nodes in the correct order.
         */
        public ArrayList Intersection(HyperCube h, AbstractNode root)
        {
            if (h == null || root == null)
            {
                throw new ArgumentException("Arguments cannot be null.");
            }

            if (h.GetDimension() != _file.Dimension)
            {
                throw new ArgumentException
                        ("HyperCube dimension different than RTree dimension.");
            }

            ArrayList v = new ArrayList();

            if (root.GetNodeMbb().Intersection(h))
            {
                v.Add(root);

                if (!root.IsLeaf())
                {
                    for (int i = 0; i < root.UsedSpace; i++)
                    {
                        if (root.Data[i].Intersection(h))
                        {
                            ArrayList a = Intersection(h, ((Index)root).GetChild(i));
                            for (int j = 0; j < a.Count; j++)
                            {
                                v.Add(a[j]);
                            }
                        }
                    }
                }
            }
            return v;
        }