src/main/java/org/jboss/util/Heap.java
public Object extract()
   {
      if (m_count < 1) {return null;}
      else
      {
         int length = m_nodes.length >> 1;
         // Shrink if necessary
         if (length > 5 && m_count < (length >> 1))
         {
            Object[] newNodes = new Object[length];
            System.arraycopy(m_nodes, 0, newNodes, 0, length);
            m_nodes = newNodes;
         }
         //
         int k = 0;
         Object ret = m_nodes[k];
         --m_count;
         Object last = m_nodes[m_count];
         for (;;)
         {
            int l = left(k);
            if (l >= m_count) {break;}
            else
            {
               int r = right(k);
               int child = (r >= m_count || compare(m_nodes[l], m_nodes[r]) < 0) ? l : r;
               if (compare(last, m_nodes[child]) > 0)
               {
                  m_nodes[k] = m_nodes[child];
                  k = child;
               }
               else {break;}
            }
         }
         m_nodes[k] = last;
         m_nodes[m_count] = null;
         return ret;
      }
   }
public Object extract()
   {
      if (m_count < 1) {return null;}
      else
      {
         int length = m_nodes.length >> 1;
         // Shrink if necessary
         if (length > 5 && m_count < (length >> 1))
         {
            Object[] newNodes = new Object[length];
            System.arraycopy(m_nodes, 0, newNodes, 0, length);
            m_nodes = newNodes;
         }
         //
         int k = 0;
         Object ret = m_nodes[k];
         --m_count;
         Object last = m_nodes[m_count];
         for (;;)
         {
            int l = left(k);
            if (l >= m_count) {break;}
            else
            {
               int r = right(k);
               int child = (r >= m_count || compare(m_nodes[l], m_nodes[r]) < 0) ? l : r;
               if (compare(last, m_nodes[child]) > 0)
               {
                  m_nodes[k] = m_nodes[child];
                  k = child;
               }
               else {break;}
            }
         }
         m_nodes[k] = last;
         m_nodes[m_count] = null;
         return ret;
      }
   }
Removes and returns the least element of this heap.
@return the extracted object

@see #insert
@see #peek