PRQuadTree / src / PRQuadtree.java
PRQuadtree.java
Raw
/**
 * Data structure of type PRQuadTree.
 * @author nickgrifasi
 * @version 10/16/21
 *
 */
public class PRQuadtree {
    
    
    
    private BaseNode parentNode;
    
    
    /**
     * static flyweight node to deal with null logic
     */
    public static final FlyWeightNode FLY_WEIGHT = 
            FlyWeightNode.getFlyWeight();
    
    /**
     * default constructor for PRQuadTree,
     * stores a placeholder flyweight into the first parentNode
     */
    public PRQuadtree()
    {
        parentNode = PRQuadtree.FLY_WEIGHT;
    }
    
    /**
     * The QuadTree dump should print the nodes 
     * of the QuadTree in preorder traversal order
     */
    public void dump()
    {
        System.out.println("QuadTree dump:");
        System.out.println(parentNode.dump(0, 0, 1024, 0) +
                " quadtree nodes printed");
    }
    
    /**
     * Inserts a point into the tree. Checks null before recursive
     * call
     * @param point point to be inserted
     */
    public void insert(Point point)
    {
        if (point != null)
        {
            parentNode = parentNode.insert(0, 0, 1024, point);
        }
    }
    
    /**
     * remove method that checks for name
     * @param point to be removed
     * @param skip name logic for SkipList
     * @return point being removed
     */
    public Point remove(Point point, boolean skip)
    {
        Point temp = parentNode.remove(0, 0, 1024, point, skip);
        parentNode.mergeTree(0, 0, 1024);
        
        
        
        return temp;
    }
    
    /**
     * find Duplicates method returns duplicates
     */
    public void findDuplicates()
    {
        parentNode.findDuplicates();
    }
}