/** * @todo * * @return a copy of this map, with the same order and same key/value pairs. */ public Object clone() throws CloneNotSupportedException { LinkedMap map; map = (LinkedMap) super.clone(); // TODO: The rest of the work is PROBABLY handled by // AbstractDecoratedMap, but need to verify that. return map; }
public Set<Entry<K, V>> entrySet() { removeExpiredEntries(); return super.entrySet(); }
/** * Removes the given entry from the Map. * * @param pEntry the entry to be removed * * @return the removed entry, or {@code null} if nothing was removed. */ protected Entry<K, V> removeEntry(Entry<K, V> pEntry) { if (pEntry == null) { return null; } // Find candidate entry for this key Entry<K, V> candidate = getEntry(pEntry.getKey()); if (candidate == pEntry || (candidate != null && candidate.equals(pEntry))) { // Remove remove(pEntry.getKey()); return pEntry; } return null; }
/** * Returns {@code true} if this map maps one or more keys to the * specified pValue. More formally, returns {@code true} if and only if * this map contains at least one mapping to a pValue {@code v} such that * {@code (pValue==null ? v==null : pValue.equals(v))}. * <p/> * This implementation requires time linear in the map size for this * operation. * * @param pValue pValue whose presence in this map is to be tested. * @return {@code true} if this map maps one or more keys to the * specified pValue. */ public boolean containsValue(Object pValue) { for (V value : values()) { if (value == pValue || (value != null && value.equals(pValue))) { return true; } } return false; }
public void clear() { entries.clear(); modCount++; init(); }
public Set<K> keySet() { removeExpiredEntries(); return super.keySet(); }
public Collection<V> values() { removeExpiredEntries(); return super.values(); }
public void clear() { mEntries.clear(); mModCount++; init(); }
public Set<K> keySet() { removeExpiredEntries(); return super.keySet(); }
/** * Removes the given entry from the Map. * * @param pEntry the entry to be removed * * @return the removed entry, or {@code null} if nothing was removed. */ protected Entry<K, V> removeEntry(Entry<K, V> pEntry) { if (pEntry == null) { return null; } // Find candidate entry for this key Entry<K, V> candidate = getEntry(pEntry.getKey()); if (candidate == pEntry || (candidate != null && candidate.equals(pEntry))) { // Remove remove(pEntry.getKey()); return pEntry; } return null; }
/** * Keeps track of timed objects */ private class TimedEntry<K, V> extends BasicEntry<K, V> { private long mTimestamp; TimedEntry(K pKey, V pValue) { super(pKey, pValue); mTimestamp = System.currentTimeMillis(); } public V setValue(V pValue) { mTimestamp = System.currentTimeMillis(); return super.setValue(pValue); } final boolean isExpired() { return isExpiredBy(System.currentTimeMillis()); } final boolean isExpiredBy(final long pTime) { return pTime > expires(); } final long expires() { return mTimestamp + expiryTime; } } }
/** * Returns {@code true} if this map maps one or more keys to the * specified pValue. More formally, returns {@code true} if and only if * this map contains at least one mapping to a pValue {@code v} such that * {@code (pValue==null ? v==null : pValue.equals(v))}. * <p/> * This implementation requires time linear in the map size for this * operation. * * @param pValue pValue whose presence in this map is to be tested. * @return {@code true} if this map maps one or more keys to the * specified pValue. */ public boolean containsValue(Object pValue) { for (V value : values()) { if (value == pValue || (value != null && value.equals(pValue))) { return true; } } return false; }
public void clear() { entries.clear(); modCount++; init(); }
/** * @todo * * @return a copy of this map, with the same order and same key/value pairs. */ public Object clone() throws CloneNotSupportedException { LinkedMap map; map = (LinkedMap) super.clone(); // TODO: The rest of the work is PROBABLY handled by // AbstractDecoratedMap, but need to verify that. return map; }
public Set<K> keySet() { removeExpiredEntries(); return super.keySet(); }
/** * Removes the given entry from the Map. * * @param pEntry the entry to be removed * * @return the removed entry, or {@code null} if nothing was removed. */ protected Entry<K, V> removeEntry(Entry<K, V> pEntry) { if (pEntry == null) { return null; } // Find candidate entry for this key Entry<K, V> candidate = getEntry(pEntry.getKey()); if (candidate == pEntry || (candidate != null && candidate.equals(pEntry))) { // Remove remove(pEntry.getKey()); return pEntry; } return null; }