예제 #1
0
            public PreOrderEnum(RTree tree)
            {
                AbstractNode root = tree._file.ReadNode(0);

                _nodes = tree.TraversePreOrder(root);
            }
예제 #2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Returns a ArrayList with all Hypercubes that completely contain point
         * <B>p</B>.
         * The HyperCubes are returned in post order traversing, according to the
         * Nodes where they belong.
         *
         * @param p The given point.
         * @param root The node where the search should begin.
         * @return A ArrayList containing the appropriate HyperCubes in the correct
         * order.
         */
        public ArrayList Enclosure(Point p, AbstractNode root)
        {
            return(Enclosure(new HyperCube(p, p), root));
        }
예제 #3
0
            public ByLevelEnum(RTree tree)
            {
                AbstractNode root = tree._file.ReadNode(0);

                _nodes = tree.TraverseByLevel(root);
            }
예제 #4
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;
        }
예제 #5
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 21DEC2008  James Shen                 	          Initial Creation
        ////////////////////////////////////////////////////////////////////////////
        /**
         * Returns a ArrayList containing all tree nodes from bottom to top, left to
         * right.
         * CAUTION: If the tree is not memory resident, all nodes will be loaded
         * into main memory.
         *
         * @param root The node from which the traverse should begin.
         * @return A ArrayList containing all Nodes in the correct order.
         */
        public ArrayList TraverseByLevel(AbstractNode root)
        {
            if (root == null)
            {
                throw new ArgumentException("Node cannot be null.");
            }

            ArrayList ret = new ArrayList();
            ArrayList v = TraversePostOrder(root);

            for (int i = 0; i <= GetTreeLevel(); i++)
            {
                ArrayList a = new ArrayList();
                for (int j = 0; j < v.Count; j++)
                {
                    INode n = (INode)v[j];
                    if (n.GetLevel() == i)
                    {
                        a.Add(n);
                    }
                }
                for (int j = 0; j < a.Count; j++)
                {
                    ret.Add(a[j]);
                }
            }

            return ret;
        }
예제 #6
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;
        }
예제 #7
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 21DEC2008  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Returns a ArrayList with all Hypercubes that completely contain point
  * <B>p</B>.
  * The HyperCubes are returned in post order traversing, according to the
  * Nodes where they belong.
  *
  * @param p The given point.
  * @param root The node where the search should begin.
  * @return A ArrayList containing the appropriate HyperCubes in the correct
  * order.
  */
 public ArrayList Enclosure(Point p, AbstractNode root)
 {
     return Enclosure(new HyperCube(p, p), root);
 }