@ SuppressWarnings ( "unchecked" ) public E replaceTopElement ( E e ) { E oldroot = ( E ) queue [ 0 ] ; heapifyDown ( 0 , e ) ; heapModified ( ) ; return oldroot ; }
Combined operation that removes the top element and inserts a new element instead .