code: public synchronized XEvent remove(int index)
  			throws IndexOutOfBoundsException, IOException {
  		// check overflow list and adjust indices
  		XEvent removed = null;
  		int smallerOverflow = 0;
  		for (int i = 0; i < overflowSize; i++) {
  			if (overflowIndices[i] == index) {
  				removed = overflowEntries[i];
  			} else if (overflowIndices[i] > index) {
  				overflowIndices[i] = overflowIndices[i] - 1;
  				if (removed != null) {
  					// move left
  					overflowIndices[i - 1] = overflowIndices[i];
  					overflowEntries[i - 1] = overflowEntries[i];
  				}
  			} else if (overflowIndices[i] < index) {
  				smallerOverflow++;
  			}
  		}
  		if (removed != null) {
  			// adjust overflow size
  			overflowSize--;
  			// invalidate entry in overflow set
  			overflowIndices[overflowSize] = -1;
  			overflowEntries[overflowSize] = null;
  		} else {
  			int bufferIndex = index - smallerOverflow;
  			for (int hole = holeFlags.nextSetBit(0); hole >= 0
  					&& hole <= bufferIndex; hole = holeFlags
  					.nextSetBit(hole + 1)) {
  				bufferIndex++;
  			}
  			removed = buffer.get(bufferIndex);
  			holeFlags.set(bufferIndex, true);
  		}
  		size--;
  		return removed;
  	}
docs: Removes the event at the given index from this list.
  
  @param index
  Index of the event to be removed.
  @return The removed event.