public void remove ( int n ) { assert this . inHeap ( n ) ; int kPos = this . indices . get ( n ) ; this . indices . set ( n , - 1 ) ; if ( kPos < this . heap . size ( ) - 1 ) { this . heap . set ( kPos , this . heap . back ( ) ) ; this . indices . set ( this . heap . get ( kPos ) , kPos ) ; this . heap . pop ( ) ; this . percolateDown ( kPos ) ; } else this . heap . pop ( ) ; }
Removes a given element of the heap .