PCJ API
Version 1.2

bak.pcj.adapter
Class ObjectKeyIntMapToMapAdapter

java.lang.Object
  extended bybak.pcj.adapter.ObjectKeyIntMapToMapAdapter
All Implemented Interfaces:
Map

public class ObjectKeyIntMapToMapAdapter
extends Object
implements Map

This class represents adapters of primitive maps from object values to values to Java Collections Framework maps. The adapter is implemented as a wrapper around a primitive map. Thus, changes to the underlying map are reflected by this map and vice versa.

Since:
1.1
See Also:
ObjectKeyIntMap, Map

Field Summary
protected  ObjectKeyIntMap map
          The underlying primitive map.
 
Constructor Summary
ObjectKeyIntMapToMapAdapter(ObjectKeyIntMap map)
          Creates a new adaption of a primitive map of object keys and int values to a Java Collections Framework map.
 
Method Summary
 void clear()
          Clears this map.
 boolean containsKey(Object key)
          Indicates whether this map contains a mapping from a specified key.
 boolean containsValue(Object value)
          Indicates whether this map contains a mapping to a specified value.
 Set entrySet()
          Returns a set view of the entries of this map.
 boolean equals(Object obj)
          Indicates whether this map is equal to some object.
 Object get(Object key)
          Maps a specified key to a value.
 int hashCode()
          Returns a hash code value for this map.
 boolean isEmpty()
          Indicates whether this map is empty.
 Set keySet()
          Returns a set view of the keys of this map.
 Object put(Object key, Object value)
          Adds a mapping from a specified key to a specified value to this map.
 void putAll(Map map)
          Adds all mappings from a specified map to this map.
 Object remove(Object key)
          Removes the mapping from a specified key from this map.
 int size()
          Returns the size of this map.
 Collection values()
          Returns a collection view of the values in this map.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected ObjectKeyIntMap map
The underlying primitive map.

Constructor Detail

ObjectKeyIntMapToMapAdapter

public ObjectKeyIntMapToMapAdapter(ObjectKeyIntMap map)
                            throws NullPointerException
Creates a new adaption of a primitive map of object keys and int values to a Java Collections Framework map.

Parameters:
map - the underlying primitive map.
Throws:
NullPointerException - if map is null.
Method Detail

clear

public void clear()
Clears this map. The underlying map is cleared.

Specified by:
clear in interface Map
Throws:
UnsupportedOperationException - if the operation is not supported by the underlying map.

containsKey

public boolean containsKey(Object key)
Indicates whether this map contains a mapping from a specified key. This is so, only if the underlying collection contains the unwrapped key.

Specified by:
containsKey in interface Map
Parameters:
key - the key to test for.
Returns:
true if this map contains a mapping from the specified key; returns false otherwise.

containsValue

public boolean containsValue(Object value)
Indicates whether this map contains a mapping to a specified value. For this map to contain an object, the underlying map must contain its unwrapped value.

Note that this map can never contain null values or values of other classes than Integer. In those cases, this method will return false.

Specified by:
containsValue in interface Map
Parameters:
value - the value to test for.
Returns:
true if this map contains at least one mapping to the specified value; returns false otherwise.

entrySet

public Set entrySet()
Returns a set view of the entries of this map. The returned set is a view, so changes to this map are reflected by the returned set and vice versa. All elements of the returned set implements java.util.Map.Entry.

Specified by:
entrySet in interface Map
Returns:
a set view of the entries of this map.

equals

public boolean equals(Object obj)
Indicates whether this map is equal to some object.

Specified by:
equals in interface Map
Parameters:
obj - the object with which to compare this map.
Returns:
true if this map is equal to the specified object; returns false otherwise.

get

public Object get(Object key)
Maps a specified key to a value. Returns null if no mapping exists for the specified key. The returned value will always be of class .

Specified by:
get in interface Map
Parameters:
key - the key to map to a value.
Returns:
the value that the specified key maps to, or null, if no such mapping exists.

hashCode

public int hashCode()
Returns a hash code value for this map. The hash code returned is that of the underlying map.

Specified by:
hashCode in interface Map
Returns:
a hash code value for this map.

isEmpty

public boolean isEmpty()
Indicates whether this map is empty.

Specified by:
isEmpty in interface Map
Returns:
true if this map is empty; returns false otherwise.

keySet

public Set keySet()
Returns a set view of the keys of this map. Removals from the returned set removes the corresponding entries in this map. Changes to the map are reflected in the set.

Specified by:
keySet in interface Map
Returns:
a set view of the keys of this map.

put

public Object put(Object key,
                  Object value)
           throws NullPointerException,
                  ClassCastException
Adds a mapping from a specified key to a specified value to this map. If a mapping already exists for the specified key it is overwritten by the new mapping. The mapping is added to the underlying map.

Specified by:
put in interface Map
Parameters:
key - the key of the mapping to add to this map.
value - the value of the mapping to add to this map.
Returns:
the old value if a mapping from the specified key already existed in this map; returns null otherwise.
Throws:
UnsupportedOperationException - if the operation is not supported by this map.
NullPointerException - if value is null.
ClassCastException - if value is not of class Integer.

putAll

public void putAll(Map map)
            throws NullPointerException,
                   ClassCastException
Adds all mappings from a specified map to this map. Any existing mappings whose keys collide with a new mapping is overwritten by the new mapping. The mappings are added to the underlying map.

Specified by:
putAll in interface Map
Parameters:
map - the map whose mappings to add to this map.
Throws:
NullPointerException - if map is null.
UnsupportedOperationException - if the operation is not supported by this map.
NullPointerException - if a value in map is null.
ClassCastException - if a value in value is not of class Integer.

remove

public Object remove(Object key)
Removes the mapping from a specified key from this map. The mapping is removed from the underlying map.

Specified by:
remove in interface Map
Parameters:
key - the key whose mapping to remove from this map.
Returns:
the old value if a mapping from the specified key already existed in this map; returns null otherwise.
Throws:
UnsupportedOperationException - if the operation is not supported by the underlying map.

size

public int size()
Returns the size of this map. The size is defined as the number of mappings from keys to values. The size is that of the underlying map.

Specified by:
size in interface Map
Returns:
the size of this map.

values

public Collection values()
Returns a collection view of the values in this map. The collection is not modifiable, but changes to the map are reflected in the collection. All elements in the returned set is of class Integer.

Specified by:
values in interface Map
Returns:
a collection view of the values in this map.

PCJ API
Version 1.2

Report a bug or request a feature.
Further information on the development and latest release of PCJ can be found at the project homepage.

Primitive Collections for Java is released under the GNU Lesser General Public License.
Copyright © 2002, 2003 Søren Bak. All Rights Reserved.

Hosted by SourceForge.net
SourceForge.net Logo