public void printCurrList() { DblLinkedList Dbl = head; while (Dbl.getNext() != null) { Console.WriteLine("" + Dbl.getNode().id + ", "); Dbl = Dbl.getNext(); } Console.WriteLine("" + Dbl.getNode().id); }
public void algoTop(Node[] node) { // check if we need to perform a convex hull algorithm. if (lessThanTwoCheck(node)) { return; } // Go through all but the first and last index's for (int trav = 2; trav < size; trav++) { // find out if the current point is part of the convex hull or not. double hCheck = hullCheck(node, prev, curr, trav); DblLinkedList DLL = new DblLinkedList(node[trav]); /* * Check if the convex Hull should be outside of the current node */ if (hCheck < curr.getNode().yVal) { /* * Check each previous node on the convex hull until up until we are sure no current * node will be fully contained in the new convex hull. */ while (prev != head) { /* * Check each new convex hull compared to the previous node. */ double newHullCheck = hullCheck(node, prev.getPrev(), prev, trav); if (newHullCheck < prev.getNode().yVal) { prev = prev.getPrev(); prev.setNext(DLL); } /* * once we verify that we've found a previous convex hull node that won't change from the * current new node, we quit. */ else { break; } } /* * This handles the same situation as directly above but takes care not to go past the * head. */ if (prev == head) { double newHullCheck = hullCheck(node, prev, prev.getNext(), trav); if (newHullCheck < prev.getNode().yVal) { prev.setNext(DLL); } } /* * update the connection between the new next convex hull node and the last verified node * on the convex hull. */ DLL.setPrev(prev); prev.setNext(DLL); } /* * If the Current Node is Outside the convex hull Then it becomes a part of the new * convex hull */ else { curr.setNext(DLL); DLL.setPrev(curr); prev = curr; } /* * update the current node along the convex hull. */ curr = DLL; // printCurrList(); } topEnd = curr; algoBottom(node); }