/** * Add an interval to this node * * @param newInterval Interval to add to this node */ public void addInterval(HTInterval newInterval) { fRwl.writeLock().lock(); try { /* Just in case, should be checked before even calling this function */ assert (newInterval.getIntervalSize() <= getNodeFreeSpace()); /* Find the insert position to keep the list sorted */ int index = fIntervals.size(); while (index > 0 && newInterval.compareTo(fIntervals.get(index - 1)) < 0) { index--; } fIntervals.add(index, newInterval); fSizeOfIntervalSection += newInterval.getIntervalSize(); /* Update the in-node offset "pointer" */ fStringSectionOffset -= (newInterval.getStringsEntrySize()); } finally { fRwl.writeLock().unlock(); } }