/** * Removes an existing listener of the given type from this eventlistener list. * * @param t the type of the listener. * @param l the listener. * @param <T> the type of the listener, must be a subclass of {@code java.util.EventListener}. */ public <T extends EventListener> void remove( final Class<T> t, final T l ) { lock.writeLock().lock(); try { final int position = findInternal( t, l ); if ( position < 0 ) { return; } final int shiftElements = size - position - 2; if ( shiftElements == 0 ) { data[ position ] = null; data[ position + 1 ] = null; size -= 2; return; } size -= 2; System.arraycopy( data, position + 2, data, position, shiftElements ); data[ size ] = null; data[ size + 1 ] = null; } finally { lock.writeLock().unlock(); } }