Top Description Fields Constructors Methods
com.google.common.graph

pack-priv Class MapIteratorCache<K, V>

extends Object
Class Inheritance
Known Direct Subclasses
com.google.common.graph.MapRetrievalCache
Annotations
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

A map-like data structure that wraps a backing map and caches values while iterating through unmodifiableKeySet(). By design, the cache is cleared when this structure is mutated. If this structure is never mutated, it provides a thread-safe view of the backing map.

The MapIteratorCache assumes ownership of the backing map, and cannot guarantee correctness in the face of external mutations to the backing map. As such, it is strongly recommended that the caller does not persist a reference to the backing map (unless the backing map is immutable).

This class is tailored toward use cases in common.graph. It is *NOT* a general purpose map.

Author
James Sexton

Field Summary

Modifier and TypeField and Description
private final Map<K, V>
private transient volatile Map.Entry<K, V>

Constructor Summary

AccessConstructor and Description
pack-priv
MapIteratorCache(Map<K, V> backingMap)

Method Summary

Modifier and TypeMethod and Description
pack-priv final void
pack-priv void
pack-priv final boolean
pack-priv V
get(Object key)

pack-priv V
pack-priv final V
pack-priv final V
put(K key, V value)

pack-priv final V
pack-priv final Set<K>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backingMapback to summary
private final Map<K, V> backingMap
cacheEntryback to summary
private transient volatile Map.Entry<K, V> cacheEntry
Annotations
@CheckForNull

Constructor Detail

MapIteratorCacheback to summary
pack-priv MapIteratorCache(Map<K, V> backingMap)

Method Detail

clearback to summary
pack-priv final void clear()
clearCacheback to summary
pack-priv void clearCache()
containsKeyback to summary
pack-priv final boolean containsKey(Object key)
getback to summary
pack-priv V get(Object key)
Annotations
@CheckForNull
getIfCachedback to summary
pack-priv V getIfCached(Object key)
Annotations
@CheckForNull
getWithoutCachingback to summary
pack-priv final V getWithoutCaching(Object key)
Annotations
@CheckForNull
putback to summary
pack-priv final V put(K key, V value)
Annotations
@CanIgnoreReturnValue
@CheckForNull
removeback to summary
pack-priv final V remove(Object key)
Annotations
@CanIgnoreReturnValue
@CheckForNull
unmodifiableKeySetback to summary
pack-priv final Set<K> unmodifiableKeySet()