Code example for Comparator

Methods: compare

0
        int left = lChild(cur);
        int right = rChild(cur);
        int smallest;
 
        if ((left < heap.size()) && 
        		(comp.compare(heap.elementAt(left), heap.elementAt(cur)) < 0)) {
			smallest = left;
		} else { 
			smallest = cur;
		} 
 
        if ((right < heap.size()) && 
        		(comp.compare(heap.elementAt(right), heap.elementAt(smallest)) < 0)) {
			smallest = right;
		} 
 
        if (cur != smallest)
        { 
            swap(cur, smallest);
            percolateDown(smallest);
Experience pair programming with AI  Get Codota for Java