title: Heap that implements Comparable in Java
body: <p>I have an array that is full of Doubles and I want to save those doubles in a heap.
  The problem is I need to keep record of the index of the array.</p>
  
  <pre><code>Double[] array = new Double[n]; //imagine it's filled with doubles
  </code></pre>
  
  <p>Now I have a PriorityQueue:</p>
  
  <pre><code>PriorityQueue&lt;Integer&gt; heap = new PriorityQueue&lt;Integer&gt;(); //Integer because it's an heap of indexes
  </code></pre>
  
  <p>I want to add each element of the array to the heap, but I want to keep record of the INDEX. 
  So imagine I add index 0 to the heap:</p>
  
  <pre><code>The heap stores 0, but uses array[0] to compare and sort it.
  Not index 0 itself, that's just like a class index. Stores v but compares v.value
  </code></pre>
  
  <p>When I get a value from the heap:</p>
  
  <pre><code>Imagine I do heap.pull();
  The heap returns me index 0, and then I will know the value is array[0].
  </code></pre>
  
  <p>Can I do this with comparable?</p>