/** * Removes the entry from the entry queue. * * @param shuffle indicates whether we are just shuffling the queue (in which case, the entry * table is not modified). */ protected void privateRemoveEntry(LRUCacheEntry entry, boolean shuffle) { LRUCacheEntry previous, next; previous = entry._fPrevious; next = entry._fNext; if (!shuffle) { fEntryTable.remove(entry._fKey); fCurrentSpace -= entry._fSpace; privateNotifyDeletionFromCache(entry); } /* if this was the first entry */ if (previous == null) { fEntryQueue = next; } else { previous._fNext = next; } /* if this was the last entry */ if (next == null) { fEntryQueueTail = previous; } else { next._fPrevious = previous; } }
/** * Adds the given entry from the receiver. * * @param shuffle Indicates whether we are just shuffling the queue (in which case, the entry * table is not modified). */ protected void privateAddEntry(LRUCacheEntry entry, boolean shuffle) { if (!shuffle) { fEntryTable.put(entry._fKey, entry); fCurrentSpace += entry._fSpace; } entry._fTimestamp = fTimestampCounter++; entry._fNext = this.fEntryQueue; entry._fPrevious = null; if (fEntryQueue == null) { /* this is the first and last entry */ fEntryQueueTail = entry; } else { fEntryQueue._fPrevious = entry; } fEntryQueue = entry; }