Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.util
Class AbstractKeySetBasedMap

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.AbstractKeyBasedMap
          extended by com.tangosol.util.AbstractKeySetBasedMap

All Implemented Interfaces:
java.util.Map
Direct Known Subclasses:
ContinuousQueryCache, OverflowMap, SerializationMap, WrapperObservableMap

public abstract class AbstractKeySetBasedMap
extends AbstractKeyBasedMap

AbstractKeySetBasedMap is an extension to the AbstractKeyBasedMap that has a full awareness of the set of keys upon which the Map is based. As a result, it is possible to optimize the implementation of a number of methods that benefit from a knowledge of the entire set of keys.

Read-only implementations must implement getInternalKeySet() and AbstractKeyBasedMap.get(Object). Read/write implementations must additionally implement AbstractKeyBasedMap.put(Object, Object) and AbstractKeyBasedMap.remove(Object). If the implementation has any cost of returning an "old value", such as is done by the Map.put(K, V) and Map.remove(Object), then the AbstractKeyBasedMap.putAll(java.util.Map) and AbstractKeyBasedMap.removeBlind(Object) methods should also be implemented. The only other obvious method for optimization is AbstractKeyBasedMap.clear(), if the implementation is able to do it in bulk.

Author:
2005.09.20 cp

Nested Class Summary
 class AbstractKeySetBasedMap.EntrySet
          A set of entries backed by this map.
 class AbstractKeySetBasedMap.KeyIterator
          An iterator over the keys from the internal key Set that implements element removal via the Map's removeBlind method.
protected  class AbstractKeySetBasedMap.KeySet
          A set of keys backed by this map.
protected  class AbstractKeySetBasedMap.ValuesCollection
          A Collection of values backed by this map.

 

Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry

 

Constructor Summary
AbstractKeySetBasedMap()
           

 

Method Summary
 boolean containsKey(java.lang.Object oKey)
          Returns true if this map contains a mapping for the specified key.
protected abstract  java.util.Set getInternalKeySet()
          Obtain a set of keys that are represented by this Map.
protected  java.util.Set instantiateEntrySet()
          Factory pattern: Create a Set that represents the entries in the Map.
protected  java.util.Iterator instantiateKeyIterator()
          Factory pattern: Create a mutable Iterator over the keys in the Map
protected  java.util.Set instantiateKeySet()
          Factory pattern: Create a Set that represents the keys in the Map
protected  java.util.Collection instantiateValues()
          Factory pattern: Instantiate the values Collection.
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
protected  boolean isInternalKeySetIteratorMutable()
          Determine if this Iterator should remove an iterated item by calling remove on the internal key Set Iterator, or by calling removeBlind on the map itself.
protected  java.util.Iterator iterateKeys()
          Create an iterator over the keys in this Map.
 int size()
          Returns the number of key-value mappings in this map.

 

Methods inherited from class com.tangosol.util.AbstractKeyBasedMap
clear, clone, containsValue, entrySet, equals, get, getAll, hashCode, keySet, put, putAll, remove, removeBlind, toString, values

 

Constructor Detail

AbstractKeySetBasedMap

public AbstractKeySetBasedMap()

Method Detail

containsKey

public boolean containsKey(java.lang.Object oKey)
Returns true if this map contains a mapping for the specified key.
Specified by:
containsKey in interface java.util.Map
Overrides:
containsKey in class AbstractKeyBasedMap
Parameters:
oKey - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key, false otherwise.

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.
Specified by:
isEmpty in interface java.util.Map
Overrides:
isEmpty in class AbstractKeyBasedMap
Returns:
true if this map contains no key-value mappings

size

public int size()
Returns the number of key-value mappings in this map.
Specified by:
size in interface java.util.Map
Overrides:
size in class AbstractKeyBasedMap
Returns:
the number of key-value mappings in this map

iterateKeys

protected java.util.Iterator iterateKeys()
Create an iterator over the keys in this Map. Note that this implementation delegates back to the key Set, while the super class delegates from the key Set to this method.
Specified by:
iterateKeys in class AbstractKeyBasedMap
Returns:
a new instance of an Iterator over the keys in this Map

getInternalKeySet

protected abstract java.util.Set getInternalKeySet()
Obtain a set of keys that are represented by this Map.

The AbstractKeySetBasedMap only utilizes the internal key set as a read-only resource.

Returns:
an internal Set of keys that are contained by this Map

isInternalKeySetIteratorMutable

protected boolean isInternalKeySetIteratorMutable()
Determine if this Iterator should remove an iterated item by calling remove on the internal key Set Iterator, or by calling removeBlind on the map itself.
Returns:
true to remove using the internal key Set Iterator or false to use the AbstractKeyBasedMap.removeBlind(Object) method

instantiateKeySet

protected java.util.Set instantiateKeySet()
Factory pattern: Create a Set that represents the keys in the Map
Overrides:
instantiateKeySet in class AbstractKeyBasedMap
Returns:
a new instance of Set that represents the keys in the Map

instantiateEntrySet

protected java.util.Set instantiateEntrySet()
Factory pattern: Create a Set that represents the entries in the Map.
Overrides:
instantiateEntrySet in class AbstractKeyBasedMap
Returns:
a new instance of Set that represents the entries in the Map

instantiateValues

protected java.util.Collection instantiateValues()
Factory pattern: Instantiate the values Collection.
Overrides:
instantiateValues in class AbstractKeyBasedMap
Returns:
a new instance of Collection that represents this Map's values

instantiateKeyIterator

protected java.util.Iterator instantiateKeyIterator()
Factory pattern: Create a mutable Iterator over the keys in the Map
Returns:
a new instance of Iterator that iterates over the keys in the Map and supports element removal

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.