/** * Updates the timestamp for the given entry, ensuring that the queue is kept in correct order. * The entry must exist */ protected void updateTimestamp(LRUCacheEntry entry) { entry._fTimestamp = fTimestampCounter++; if (fEntryQueue != entry) { this.privateRemoveEntry(entry, true); this.privateAddEntry(entry, true); } return; }
/** * 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; }