Advertisement
Aldin-SXR

insert()

May 5th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.22 KB | None | 0 0
  1. /* Insert a new element into the priority queue */
  2. public void insert(Item data) {
  3.     if (pq.length == length + 1) {          // 1
  4.         resize(2 * pq.length);              // 1
  5.     }
  6.     pq[++length] = data;                    // 2
  7.     swim(length);                           // 3
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement