Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.util.Comparator;
  2.  
  3. final class DefaultComparator implements Comparator {
  4.  
  5. public int compare(Object a, Object b) {
  6. return ((Comparable)a).compareTo(b);
  7. }
  8. }
  9.  
  10. public class MaxPQ {
  11. private Object[] heap;
  12. private int size;
  13. protected Comparator cmp;
  14.  
  15.  
  16.  
  17. public MaxPQ (int capacity, Comparator cmp) {
  18. if (capacity < 1) throw new IllegalArgumentException();
  19. this.heap = new Object[capacity+1];
  20. this.size = 0;
  21. this.cmp = cmp;
  22. }
  23.  
  24. public MaxPQ (int capacity) {
  25. this(capacity, new DefaultComparator());
  26. }
  27.  
  28.  
  29.  
  30. public void insert (Object object) {
  31.  
  32. }
  33.  
  34. public Object getMax () {
  35.  
  36. }
  37.  
  38. private void swim (int i) {
  39.  
  40. }
  41.  
  42. private void sink (int i) {
  43.  
  44. }
  45.  
  46. private void swap (int i, int j) {
  47.  
  48. }
  49.  
  50. public void print () {
  51.  
  52. }
  53.  
  54. boolean empty () {
  55.  
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement