protected void offerAt ( final int pos , O e ) { if ( pos == NO_VALUE ) { // resize when needed if ( size + 1 > queue . length ) { resize ( size + 1 ) ; } index . put ( e , size ) ; size ++ ; heapifyUp ( size - 1 , e ) ; heapModified ( ) ; return ; } assert ( pos >= 0 ) : "Unexpected negative position." ; assert ( queue [ pos ] . equals ( e ) ) ; // Did the value improve? if ( comparator . compare ( e , queue [ pos ] ) >= 0 ) { return ; } heapifyUp ( pos , e ) ; heapModified ( ) ; return ; }
Offer element at the given position .