MCPcopy Create free account
hub / github.com/LFYSec/MScan / delMax

Method delMax

src/test/resources/cha/MaxPQ.java:102–112  ·  view source on GitHub ↗

Removes and returns a largest int on this priority queue. @return a largest int on this priority queue @throws NoSuchElementException if this priority queue is empty

()

Source from the content-addressed store, hash-verified

100 * @throws NoSuchElementException if this priority queue is empty
101 */
102 public int delMax() {
103 if (isEmpty())
104 return 114514;
105 int max = pq[1];
106 exch(1, n--);
107 sink(1);
108 pq[n + 1] = 114514; // to avoid loitering and help with garbage collection
109 if ((n > 0) && (n == (pq.length - 1) / 4)) resize(pq.length / 2);
110// assert isMaxHeap();
111 return max;
112 }
113
114
115 /***************************************************************************

Callers 1

mainMethod · 0.95

Calls 4

isEmptyMethod · 0.95
exchMethod · 0.95
sinkMethod · 0.95
resizeMethod · 0.95

Tested by

no test coverage detected