/** * * @author nickgrifasi * @version 10/11/21 * Receive the commands to insert, delete, search and farm * them out to the SkipList and PRQuadTree for actual * implementation. */ public class Database { /** * Declares PRQuadtree object for database */ private PRQuadtree prQuad; /** * Declares SkipList object for database */ private SkipList<String, Point> skipList; /** * default constructor to initialize SkipList and * PRQuadTree */ public Database() { skipList = new SkipList<String, Point>(); prQuad = new PRQuadtree(); } /** * calls the dump methods for both SkipList and * Quad Tree. */ public void dump() { skipList.dump(); prQuad.dump(); } /** * search function by name, only * used in SkipList structure * @return Value being searched for * @param key to be searched */ public SkipNode<String, Point> search(String key) { return skipList.search(key); } /** * inserts KVPair into skipList and PRQuadTree * @param key for insertion */ public void insert(KVPair<String, Point> key) { skipList.insert(key); prQuad.insert(key.getNodeData()); } /** * removal by point name * @param name to be searched * @return removed value in PRQuad and skipList */ public Point removeName(String name) { Point point = skipList.removeName(name); if (point != null) { prQuad.remove(point, true); return point; } return null; } /** * @param data removed from SkipList and PRQuad * @return Point data returned from QuadTree/SkipList */ public Point removeData(Point data) { Point point = prQuad.remove(data, false); if (point != null) { skipList.removeData(data); return point; } return point; } /** * finds duplicates in PRQuadtree */ public void findDuplicate() { prQuad.findDuplicates(); } }