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

Method insert

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

Adds a new int to this priority queue. @param x the new int to add to this priority queue

(int x)

Source from the content-addressed store, hash-verified

84 * @param x the new int to add to this priority queue
85 */
86 public void insert(int x) {
87 // double size of array if necessary
88 if (n == pq.length - 1) resize(2 * pq.length);
89
90 // add x, and percolate it up to maintain heap invariant
91 pq[++n] = x;
92 swim(n);
93// assert isMaxHeap();
94 }
95
96 /**
97 * Removes and returns a largest int on this priority queue.

Callers 1

mainMethod · 0.95

Calls 2

resizeMethod · 0.95
swimMethod · 0.95

Tested by

no test coverage detected