1 15 16 package EDU.oswego.cs.dl.util.concurrent; 17 import java.util.Comparator ; 18 import java.lang.reflect.*; 19 20 44 45 public class BoundedPriorityQueue extends SemaphoreControlledChannel { 46 protected final Heap heap_; 47 48 52 53 public BoundedPriorityQueue(int capacity, Comparator cmp) 54 throws IllegalArgumentException { 55 super(capacity); 56 heap_ = new Heap(capacity, cmp); 57 } 58 59 63 64 public BoundedPriorityQueue(Comparator comparator) { 65 this(DefaultChannelCapacity.get(), comparator); 66 } 67 68 72 73 public BoundedPriorityQueue(int capacity) { 74 this(capacity, null); 75 } 76 77 81 82 public BoundedPriorityQueue() { 83 this(DefaultChannelCapacity.get(), null); 84 } 85 86 87 100 101 public BoundedPriorityQueue(int capacity, Comparator cmp, 102 Class semaphoreClass) 103 throws IllegalArgumentException , 104 NoSuchMethodException , 105 SecurityException , 106 InstantiationException , 107 IllegalAccessException , 108 InvocationTargetException { 109 super(capacity, semaphoreClass); 110 heap_ = new Heap(capacity, cmp); 111 } 112 113 protected void insert(Object x) { heap_.insert(x); } 114 protected Object extract() { return heap_.extract(); } 115 public Object peek() { return heap_.peek(); } 116 117 } 118 | Popular Tags |