public synchronized void insert ( XEvent event , int index ) throws IndexOutOfBoundsException , IOException { if ( index < 0 || index > size ) { throw new IndexOutOfBoundsException ( ) ; } // check if we can append if ( index == size ) { append ( event ) ; return ; } // adjust size and overflow size size ++ ; overflowSize ++ ; // add to overflow set for ( int i = overflowSize - 2 ; i >= 0 ; i -- ) { if ( overflowIndices [ i ] >= index ) { overflowIndices [ i + 1 ] = overflowIndices [ i ] + 1 ; overflowEntries [ i + 1 ] = overflowEntries [ i ] ; } else { overflowIndices [ i + 1 ] = index ; overflowEntries [ i + 1 ] = event ; if ( overflowSize == overflowIndices . length ) { consolidate ( ) ; } return ; } } // if we arrive here, we must insert at zero overflowIndices [ 0 ] = index ; overflowEntries [ 0 ] = event ; if ( overflowSize == overflowIndices . length ) { consolidate ( ) ; } }
Inserts an event at a given index into the list .