T (int key) { ++myAttempts; final int index = searchForCacheEntry(key); if (index == 0) { return null; } ++myHits; final CacheEntry<T> cacheEntry = myCache[index]; final int top = myTop; if (index != top) { final int prev = cacheEntry.prev; final int next = cacheEntry.next; if (index == myBack) { myBack = prev; } else { myCache[next].prev = prev; } myCache[prev].next = next; cacheEntry.next = top; cacheEntry.prev = 0; myCache[top].prev = index; myTop = index; } return cacheEntry.value; }