/** * Gets the value mapped to the key specified. * <p> * This operation changes the position of the key in the map to the * most recently used position (first). * * @param key the key * @return the mapped value, null if no match */ public Object get(Object key) { LinkEntry entry = (LinkEntry) getEntry(key); if (entry == null) { return null; } moveToMRU(entry); return entry.getValue(); }
/** * Gets the value mapped to the key specified. * <p> * This operation changes the position of the key in the map to the * most recently used position (first). * * @param key the key * @return the mapped value, null if no match */ public Object get(Object key) { LinkEntry entry = (LinkEntry) getEntry(key); if (entry == null) { return null; } moveToMRU(entry); return entry.getValue(); }
public void testInternalState_getEntry_int() { if (isPutAddSupported() == false || isPutChangeSupported() == false) return; SingleHashCode one = new SingleHashCode("1"); SingleHashCode two = new SingleHashCode("2"); SingleHashCode three = new SingleHashCode("3"); SingleHashCode four = new SingleHashCode("4"); SingleHashCode five = new SingleHashCode("5"); SingleHashCode six = new SingleHashCode("6"); LRUMap map = new LRUMap(3, 1.0f); int hashIndex = map.hashIndex(map.hash(one), 4); map.put(one, "A"); map.put(two, "B"); map.put(three, "C"); assertEquals(one, map.getEntry(0).key); assertEquals(two, map.getEntry(1).key); assertEquals(three, map.getEntry(2).key); try { map.getEntry(-1); fail(); } catch (IndexOutOfBoundsException ex) {} try { map.getEntry(3); fail(); } catch (IndexOutOfBoundsException ex) {} }
/** * Gets the value mapped to the key specified. * <p> * This operation changes the position of the key in the map to the * most recently used position (first). * * @param key the key * @return the mapped value, null if no match */ public Object get(Object key) { LinkEntry entry = (LinkEntry) getEntry(key); if (entry == null) { return null; } moveToMRU(entry); return entry.getValue(); }
/** * Gets the value mapped to the key specified. * <p> * This operation changes the position of the key in the map to the * most recently used position (first). * * @param key the key * @return the mapped value, null if no match */ public Object get(Object key) { LinkEntry entry = (LinkEntry) getEntry(key); if (entry == null) { return null; } moveToMRU(entry); return entry.getValue(); }
/** * Gets the value mapped to the key specified. * <p> * This operation changes the position of the key in the map to the * most recently used position (first). * * @param key the key * @return the mapped value, null if no match */ public Object get(Object key) { LinkEntry entry = (LinkEntry) getEntry(key); if (entry == null) { return null; } moveToMRU(entry); return entry.getValue(); }
/** * Gets the value mapped to the key specified. * <p> * This operation changes the position of the key in the map to the * most recently used position (first). * * @param key the key * @return the mapped value, null if no match */ public Object get(Object key) { LinkEntry entry = (LinkEntry) getEntry(key); if (entry == null) { return null; } moveToMRU(entry); return entry.getValue(); }
/** * Gets the value mapped to the key specified. * <p> * This operation changes the position of the key in the map to the * most recently used position (first). * * @param key the key * @return the mapped value, null if no match */ public Object get(Object key) { LinkEntry entry = (LinkEntry) getEntry(key); if (entry == null) { return null; } moveToMRU(entry); return entry.getValue(); }
/** * @see org.apache.commons.collections.map.AbstractHashedMap#getEntry(java.lang.Object) */ protected HashEntry getEntry(Object key) { final TrackingHashEntry entry = (TrackingHashEntry)super.getEntry(key); if (entry == null) { this.missCount++; return null; } final long now = System.currentTimeMillis(); if ((this.timeToLive > 0 && (now - entry.getCreationTime()) / 1000 >= this.timeToLive) || (this.timeToIdle > 0 && (now - entry.getAccessTime()) / 1000 >= this.timeToIdle)) { this.remove(key); this.missCount++; this.expirationCount++; return null; } entry.setAccessTime(now); this.hitCount++; return entry; }