|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.util.AbstractKeyBasedMap
public abstract class AbstractKeyBasedMap
AbstractKeyBasedMap is a base class for Map implementations. The primary
difference between the AbstractMap
abstract class and
this abstract class is this: that AbstractMap requires a sub-class to
provide an Entry Set implementation, while AbstractKeyBasedMap requires a
read-only sub-class to implement only get() and iterateKeys(), and a
read-write sub-class to additionally implement only put() and remove().
iterateKeys()
and
get(Object)
. Read/write implementations must additionally
implement put(Object, Object)
and remove(Object)
. A
number of the methods have implementations provided, but are extremely
inefficient for Maps that contain large amounts of data, including
clear()
, containsKey(Object)
, size()
(and by
extension isEmpty()
). Furthermore, if any of a number of method
implementations has any cost of returning an "old value", such as is done
by the put(java.lang.Object, java.lang.Object)
and remove(Object)
methods, then the
putAll(java.util.Map)
and removeBlind(Object)
methods should also be implemented.
Nested Class Summary | |
---|---|
class |
AbstractKeyBasedMap.EntrySet
A set of entries backed by this map. |
protected class |
AbstractKeyBasedMap.KeySet
A set of keys backed by this map. |
protected class |
AbstractKeyBasedMap.ValuesCollection
A Collection of values backed by this map. |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry |
Constructor Summary | |
---|---|
AbstractKeyBasedMap()
|
Method Summary | |
---|---|
void |
clear()
Clear all key/value mappings. |
protected Object |
clone()
Returns a shallow copy of this AbstractKeyBasedMap instance; the keySet, entrySet and values collections are not cloned or copied to (shared by) the clone. |
boolean |
containsKey(Object oKey)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(Object oValue)
Returns true if this Map maps one or more keys to the specified value. |
Set |
entrySet()
Returns a set view of the mappings contained in this map. |
boolean |
equals(Object o)
Compares the specified object with this map for equality. |
abstract Object |
get(Object oKey)
Returns the value to which this map maps the specified key. |
Map |
getAll(Collection colKeys)
Get all the specified keys, if they are in the Map. |
int |
hashCode()
Returns the hash code value for this Map. |
protected Set |
instantiateEntrySet()
Factory pattern: Create a Set that represents the entries in the Map. |
protected Set |
instantiateKeySet()
Factory pattern: Create a Set that represents the keys in the Map |
protected Collection |
instantiateValues()
Factory pattern: Instantiate the values Collection. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
protected abstract Iterator |
iterateKeys()
Create an iterator over the keys in this Map. |
Set |
keySet()
Returns a set view of the keys contained in this map. |
Object |
put(Object oKey,
Object oValue)
Associates the specified value with the specified key in this map. |
void |
putAll(Map map)
Copies all of the mappings from the specified map to this map. |
Object |
remove(Object oKey)
Removes the mapping for this key from this map if present. |
protected boolean |
removeBlind(Object oKey)
Removes the mapping for this key from this map if present. |
int |
size()
Returns the number of key-value mappings in this map. |
String |
toString()
Returns a string representation of this Map. |
Collection |
values()
Returns a collection view of the values contained in this map. |
Constructor Detail |
---|
public AbstractKeyBasedMap()
Method Detail |
---|
public void clear()
clear
in interface Map
public boolean containsKey(Object oKey)
containsKey
in interface Map
public boolean containsValue(Object oValue)
containsValue
in interface Map
public Set entrySet()
AbstractKeyBasedMap.EntrySet.Entry
. The set is backed by the
map, so changes to the map are reflected in the set, and vice-versa.
If the map is modified while an iteration over the set is in progress
(except by the iterator's own remove operation, or by the
setValue operation on a map entry returned by the iterator)
the results of the iteration are undefined. The set supports element
removal, which removes the corresponding mapping from the map, via the
Iterator.remove, Set.remove, removeAll,
retainAll and clear operations. It is not expected to
support the add or addAll operations.
entrySet
in interface Map
public abstract Object get(Object oKey)
get
in interface Map
oKey
- the key object
public boolean isEmpty()
isEmpty
in interface Map
public Set keySet()
keySet
in interface Map
public Object put(Object oKey, Object oValue)
put
in interface Map
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified key
public void putAll(Map map)
put(java.lang.Object, java.lang.Object)
on this map once for each mapping in the passed map. The behavior of
this operation is unspecified if the passed map is modified while the
operation is in progress.
putAll
in interface Map
map
- the Map containing the key/value pairings to put into this
Mappublic Object remove(Object oKey)
remove
in interface Map
oKey
- key whose mapping is to be removed from the map
public int size()
size
in interface Map
public Collection values()
values
in interface Map
public Map getAll(Collection colKeys)
colKeys
- a collection of keys that may be in the named cache
protected abstract Iterator iterateKeys()
protected boolean removeBlind(Object oKey)
oKey
- key whose mapping is to be removed from the map
public boolean equals(Object o)
equals
in interface Map
o
- object to be compared for equality with this Map
public int hashCode()
hashCode
in interface Map
public String toString()
protected Object clone() throws CloneNotSupportedException
CloneNotSupportedException
protected Set instantiateKeySet()
protected Set instantiateEntrySet()
protected Collection instantiateValues()
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |