Copyright (c) 2012, Magnetic Bear Studios Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditio...
If you think the Android project scala1_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.koushikdutta.urlimageviewhelper;
/*www.java2s.com*/import java.lang.ref.SoftReference;
import java.util.Hashtable;
publicclass SoftReferenceHashTable<K,V> {
Hashtable<K, SoftReference<V>> mTable = new Hashtable<K, SoftReference<V>>();
public V put(K key, V value) {
SoftReference<V> old = mTable.put(key, new SoftReference<V>(value));
if (old == null)
return null;
return old.get();
}
public V get(K key) {
SoftReference<V> val = mTable.get(key);
if (val == null)
return null;
V ret = val.get();
if (ret == null)
mTable.remove(key);
return ret;
}
public V remove(K k) {
SoftReference<V> v = mTable.remove(k);
if (v == null)
return null;
return v.get();
}
}