code: public synchronized boolean replace(XEvent event, int index)
  			throws IOException {
  		// check for index sanity
  		if (index < 0 || index >= size) {
  			throw new IndexOutOfBoundsException();
  		}
  		// determine and set appropriate file pointer position
  		navigateToIndex(index);
  		storage.seek(position);
  		long atePosition = position;
  		// read navigation data
  		int fwd = storage.readInt();
  		// skip backwards pointer and payload size, not relevant
  		storage.skipBytes(8);
  		int segmentSize = fwd - 12;
  		// encode event
  		byte[] evtEnc = encode(event);
  		boolean success = false;
  		if (evtEnc.length <= segmentSize) {
  			// overwrite event
  			storage.seek(atePosition + 8);
  			storage.writeInt(evtEnc.length);
  			// insert new padding
  			byte segmentPadding[] = new byte[segmentSize - evtEnc.length];
  			Arrays.fill(segmentPadding, (byte) 0);
  			storage.write(evtEnc);
  			storage.write(segmentPadding);
  			success = true;
  		} else {
  			success = false;
  		}
  		// return to prior position
  		this.position = atePosition;
  		storage.seek(this.position);
  		return success;
  	}
docs: Replaces an event at the given position.
  
  @param event
  The new event to be inserted.
  @param index
  Index to replace at.
  @return The former event, having been replaced.