@SuppressWarnings("unchecked") public void insert(int id,Comparable<E> priority){
  int i;
  i=++_n;
  ElementH p=new ElementH();
  while (i > 1) {
    int pIdx=i / 2;
    ElementH eIdx=(ElementH)_elements[pIdx];
    p.id=eIdx.id;
    p.priority=eIdx.priority;
    if (priority.compareTo((E)p.priority) > 0) {
      break;
    }
    ElementH ei=(ElementH)_elements[i];
    ei.id=p.id;
    ei.priority=p.priority;
    _pos[p.id]=i;
    i=pIdx;
  }
  ElementH ei=(ElementH)_elements[i];
  ei.id=id;
  ei.priority=priority;
  _pos[id]=i;
}

@ SuppressWarnings ( "unchecked" ) public void insert ( int id , Comparable < E > priority ) { int i ; i = ++ _n ; ElementH p = new ElementH ( ) ; while ( i > 1 ) { int pIdx = i / 2 ; ElementH eIdx = ( ElementH ) _elements [ pIdx ] ; p . id = eIdx . id ; p . priority = eIdx . priority ; if ( priority . compareTo ( ( E ) p . priority ) > 0 ) { break ; } ElementH ei = ( ElementH ) _elements [ i ] ; ei . id = p . id ; ei . priority = p . priority ; _pos [ p . id ] = i ; i = pIdx ; } ElementH ei = ( ElementH ) _elements [ i ] ; ei . id = id ; ei . priority = priority ; _pos [ id ] = i ; }
insert the element ( id ) with given priority . < p > inserting too many items into a binary heap will cause exception .
