cz.cuni.amis.utils.maps
Class AbstractLazyMap<KEY,VALUE>
java.lang.Object
cz.cuni.amis.utils.maps.AbstractLazyMap<KEY,VALUE>
- Type Parameters:
KEY
- KeyTypeVALUE
- ValueType
- All Implemented Interfaces:
- Map<KEY,VALUE>
public abstract class AbstractLazyMap<KEY,VALUE>
- extends Object
- implements Map<KEY,VALUE>
Abstract implementation of a lazy map.
The values are created on-demand by the create method if they are not cached already.
The keySet is kept updated however, only the values are lazy-generated.
If you need to iterate over the map, but you don't actually need all the values, iterate over the keySet.
- Author:
- srlok
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractLazyMap
public AbstractLazyMap()
AbstractLazyMap
public AbstractLazyMap(Set<KEY> entryKeySet)
AbstractLazyMap
public AbstractLazyMap(Map<KEY,VALUE> baseMap)
create
protected abstract VALUE create(Object key)
- Creates the Mapped object based on its key. Every LazyMap must implement this.
- Parameters:
key
-
- Returns:
addKey
public void addKey(KEY key)
clear
public void clear()
- Specified by:
clear
in interface Map<KEY,VALUE>
clearCache
public void clearCache()
- manually clears the cached objects
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interface Map<KEY,VALUE>
setKeySet
public void setKeySet(Set<KEY> newKeySet)
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interface Map<KEY,VALUE>
entrySet
public Set<Map.Entry<KEY,VALUE>> entrySet()
- Specified by:
entrySet
in interface Map<KEY,VALUE>
get
public VALUE get(Object key)
- Specified by:
get
in interface Map<KEY,VALUE>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interface Map<KEY,VALUE>
keySet
public Set<KEY> keySet()
- Specified by:
keySet
in interface Map<KEY,VALUE>
put
public VALUE put(KEY key,
VALUE value)
- Specified by:
put
in interface Map<KEY,VALUE>
putAll
public void putAll(Map<? extends KEY,? extends VALUE> m)
- Specified by:
putAll
in interface Map<KEY,VALUE>
remove
public VALUE remove(Object key)
- Specified by:
remove
in interface Map<KEY,VALUE>
size
public int size()
- Specified by:
size
in interface Map<KEY,VALUE>
values
public Collection<VALUE> values()
- Specified by:
values
in interface Map<KEY,VALUE>
Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.