org.eclipse.internal.xtend.util
Class IdentityCacheWithoutNull<K,V>
java.lang.Object
org.eclipse.internal.xtend.util.IdentityCacheWithoutNull<K,V>
- Type Parameters:
K
- The type for the cache's keyV
- The type for the cache's value
public abstract class IdentityCacheWithoutNull<K,V>
- extends java.lang.Object
This cache treats keys as the same only if they are identical: (key1 == key2)
This cache does not store null values, which means that if createNew(key)
returns null for a specific key the result is not cached and createNew(key)
is called again every time the key's value is requested.
Not to cache the null-value provides the advantage that a single lookup in
the internal HashMap "get()" is enough to server one request. Otherwise it
would be necessary to do a "containsKey()" first and then the "get()" which
costs the time of two lookups.
- Author:
- Moritz Eysholdt
Field Summary |
protected java.util.IdentityHashMap<K,V> |
internal
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
internal
protected java.util.IdentityHashMap<K,V> internal
IdentityCacheWithoutNull
public IdentityCacheWithoutNull()
createNew
protected abstract V createNew(K key)
get
public V get(K key)