Advertisement
Aldin-SXR

resize()

May 5th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.30 KB | None | 0 0
  1. /* Create a new internal array with a given capacity */
  2. @SuppressWarnings("unchecked")
  3. private void resize(int capacity) {
  4.     Item[] copy = (Item[]) new Comparable[capacity];        // 1
  5.     for (int i = 1; i <= length; i++) {                     // 2
  6.         copy[i] = pq[i];                                    // 2
  7.     }                                              
  8.     pq = copy;                                              // 3
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement