Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Comparator;
- final class DefaultComparator implements Comparator {
- public int compare(Object a, Object b) {
- return ((Comparable)a).compareTo(b);
- }
- }
- public class MaxPQ {
- private Object[] heap;
- private int size;
- protected Comparator cmp;
- public MaxPQ (int capacity, Comparator cmp) {
- if (capacity < 1) throw new IllegalArgumentException();
- this.heap = new Object[capacity+1];
- this.size = 0;
- this.cmp = cmp;
- }
- public MaxPQ (int capacity) {
- this(capacity, new DefaultComparator());
- }
- public void insert (Object object) {
- }
- public Object getMax () {
- }
- private void swim (int i) {
- }
- private void sink (int i) {
- }
- private void swap (int i, int j) {
- }
- public void print () {
- }
- boolean empty () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement