@Override public void clear() { optimizeWrites(); store.clear(); fireIntervalRemoved(this, null, null); }
/** * Call the support mechanism in AbstractPassage * * @param in * The stream to read our state from * @serialData Write the ordinal number of this verse * @throws IOException * if the read fails * @throws ClassNotFoundException * If the read data is incorrect * @see AbstractPassage#readObjectSupport(ObjectInputStream) */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { optimizeWrites(); store = new TreeSet<VerseRange>(); in.defaultReadObject(); readObjectSupport(in); }
public void add(Key obj) { optimizeWrites(); VerseRange thatRange = toVerseRange(getVersification(), obj); store.add(thatRange); normalize(); // we do an extra check here because the cost of calculating the // params is non-zero an may be wasted if (suppressEvents == 0) { fireIntervalAdded(this, thatRange.getStart(), thatRange.getEnd()); } }
@Override public void retainAll(Key key) { optimizeWrites();
public void remove(Key obj) { optimizeWrites(); VerseRange thatRange = toVerseRange(getVersification(), obj); boolean removed = false; // This allows us to modify store which iterating through a copy Set<Key> newStore = new TreeSet<Key>(); newStore.addAll(store); // go through all the VerseRanges for (Key aKey : newStore) { // if this range touches the range to be removed ... VerseRange thisRange = (VerseRange) aKey; if (thisRange.overlaps(thatRange)) { // ... remove it and add the remainder store.remove(thisRange); VerseRange[] vra = VerseRange.remainder(thisRange, thatRange); for (int i = 0; i < vra.length; i++) { store.add(vra[i]); } removed = true; } } if (removed) { normalize(); } // we do an extra check here because the cost of calculating the // params is non-zero an may be wasted if (suppressEvents == 0) { fireIntervalRemoved(this, thatRange.getStart(), thatRange.getEnd()); } }