public synchronized XEvent replace ( XEvent event , int index ) throws IndexOutOfBoundsException , IOException { // check overflow list and adjust indices XEvent replaced = null ; int smallerOverflow = 0 ; for ( int i = 0 ; i < overflowSize ; i ++ ) { if ( overflowIndices [ i ] == index ) { replaced = overflowEntries [ i ] ; overflowEntries [ i ] = event ; return replaced ; } else if ( overflowIndices [ i ] > index ) { // done break ; } else if ( overflowIndices [ i ] < index ) { smallerOverflow ++ ; } } // still here: we must look in file buffer int bufferIndex = index - smallerOverflow ; for ( int hole = holeFlags . nextSetBit ( 0 ) ; hole >= 0 && hole <= bufferIndex ; hole = holeFlags . nextSetBit ( hole + 1 ) ) { bufferIndex ++ ; } replaced = buffer . get ( bufferIndex ) ; if ( buffer . replace ( event , bufferIndex ) == false ) { remove ( index ) ; insert ( event , index ) ; } return replaced ; }
Replaces the event at the given index with another event .