/** * Take the verses in the tally and give them all and equal rank of 1. After * this method has executed then both sorting methods for a. */ public void flatten() { optimizeWrites(); for (int i = 0; i < board.length; i++) { if (board[i] != 0) { board[i] = 1; } } max = 1; }
/** * Sometimes we end up not knowing what the max is - this makes sure we know * accurately. Same with size. */ private void resetMax() { optimizeWrites(); max = 0; size = 0; for (int i = 0; i < board.length; i++) { if (board[i] > 0) { size++; } if (board[i] > max) { max = board[i]; } } }
@Override public void clear() { optimizeWrites(); for (int i = 0; i < board.length; i++) { board[i] = 0; } size = 0; fireIntervalRemoved(this, null, null); }
/** * Call the support mechanism in AbstractPassage * * @param in * The stream to read our state from * @throws IOException * if the read fails * @throws ClassNotFoundException * If the read data is incorrect * @serialData Write the ordinal number of this verse * @see AbstractPassage#readObjectSupport(ObjectInputStream) */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { optimizeWrites(); in.defaultReadObject(); readObjectSupport(in); }
/** * Add/Increment this verses in the rankings * * @param that * The verses to add/increment */ public void add(Key that) { optimizeWrites(); alterVerseBase(that, 1); fireIntervalAdded(this, null, null); }
/** * Remove/Decrement this verses in the rankings * * @param that * The verses to remove/decrement */ public void unAdd(Key that) { optimizeWrites(); alterVerseBase(that, -1); fireIntervalRemoved(this, null, null); }
/** * DONT USE THIS. It makes public something of the ratings scheme which is * not generally recommended. This method is likely to be removed at a * moments notice, and it only here to keep Mapper happy. Add/Increment this * verses in the rankings * * @param that * The verses to add/increment * @param count * The amount to increment by */ public void add(Key that, int count) { optimizeWrites(); alterVerseBase(that, count); fireIntervalAdded(this, null, null); }
/** * Remove these verses from the rankings, ie, set their rank to zero. * * @param that * The verses to remove/decrement */ public void remove(Key that) { optimizeWrites(); for (Key aKey : that) { Verse verse = (Verse) aKey; kill(verse.getOrdinal()); } fireIntervalRemoved(this, null, null); }
@Override public void removeAll(Key key) { optimizeWrites(); if (key instanceof PassageTally) { PassageTally tally = (PassageTally) key; int vib = getVersification().maximumOrdinal(); for (int i = 0; i <= vib; i++) { if (tally.board[i] != 0) { kill(i); } } } else { for (Key aKey : key) { Verse verse = (Verse) aKey; kill(verse.getOrdinal()); } } fireIntervalRemoved(this, null, null); // Just because we've decremented some doesn't // change the max. So we don't need to do: // incrementMax(-1); }
/** * Remove/Decrement these verses in the rankings * * @param that * The verses to remove/decrement */ public void unAddAll(Passage that) { optimizeWrites(); if (that instanceof PassageTally) { PassageTally tally = (PassageTally) that; int vib = getVersification().maximumOrdinal(); for (int i = 0; i <= vib; i++) { increment(i, -tally.board[i]); } } else { for (Key aKey : that) { Verse verse = (Verse) aKey; increment(verse.getOrdinal(), -1); } } fireIntervalRemoved(this, null, null); // Just because we've decremented some doesn't // change the max. So we don't need to do: // incrementMax(-1); }
assert verses >= 0; optimizeWrites(); raiseEventSuppresion(); raiseNormalizeProtection();
@Override public void addAll(Key that) { optimizeWrites(); if (that instanceof PassageTally) { PassageTally tally = (PassageTally) that; int vib = getVersification().maximumOrdinal(); for (int i = 0; i <= vib; i++) { increment(i, tally.board[i]); } incrementMax(tally.max); } else { for (Key aKey : that) { Verse verse = (Verse) aKey; increment(verse.getOrdinal(), 1); } incrementMax(1); } fireIntervalAdded(this, null, null); }