gnu.trove.decorator

Class TIntFloatHashMapDecorator

Implemented Interfaces:
Cloneable, Map

public class TIntFloatHashMapDecorator
extends AbstractMap
implements Map, Cloneable

Wrapper class to make a TIntFloatHashMap conform to the java.util.Map API. This class simply decorates an underlying TIntFloatHashMap and translates the Object-based APIs into their Trove primitive analogs.

Note that wrapping and unwrapping primitive values is extremely inefficient. If possible, users of this class should override the appropriate methods in this class and use a table of canonical values.

Created: Mon Sep 23 22:07:40 PDT 2002

Authors:
Eric D. Friedman
Rob Eden

Field Summary

protected TIntFloatHashMap
_map
the wrapped primitive map

Constructor Summary

TIntFloatHashMapDecorator(TIntFloatHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Summary

void
clear()
Empties the map.
TIntFloatHashMapDecorator
clone()
Clones the underlying trove collection and returns the clone wrapped in a new decorator instance.
boolean
containsKey(Object key)
Checks for the present of key in the keys of the map.
boolean
containsValue(Object val)
Checks for the presence of val in the values of the map.
Set>
entrySet()
Returns a Set view on the entries of the map.
boolean
equals(Object other)
Compares this map with another map for equality of their stored entries.
Float
get(Integer key)
Retrieves the value for key
TIntFloatHashMap
getMap()
Returns a reference to the map wrapped by this decorator.
boolean
isEmpty()
Indicates whether map has any entries.
Float
put(Integer key, Float value)
Inserts a key/value pair into the map.
void
putAll(extends Integer, Float> map)
Copies the key/value mappings in map into this map.
Float
remove(Integer key)
Deletes a key/value pair from the map.
int
size()
Returns the number of entries in the map.
protected int
unwrapKey(Object key)
Unwraps a key
protected float
unwrapValue(Object value)
Unwraps a value
protected Integer
wrapKey(int k)
Wraps a key
protected Float
wrapValue(float k)
Wraps a value

Field Details

_map

protected TIntFloatHashMap _map
the wrapped primitive map

Constructor Details

TIntFloatHashMapDecorator

public TIntFloatHashMapDecorator(TIntFloatHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Details

clear

public void clear()
Empties the map.

clone

public TIntFloatHashMapDecorator clone()
Clones the underlying trove collection and returns the clone wrapped in a new decorator instance. This is a shallow clone except where primitives are concerned.
Returns:
a copy of the receiver

containsKey

public boolean containsKey(Object key)
Checks for the present of key in the keys of the map.
Parameters:
key - an Object value
Returns:
a boolean value

containsValue

public boolean containsValue(Object val)
Checks for the presence of val in the values of the map.
Parameters:
val - an Object value
Returns:
a boolean value

entrySet

public Set> entrySet()
Returns a Set view on the entries of the map.
Returns:
a Set value

equals

public boolean equals(Object other)
Compares this map with another map for equality of their stored entries.
Parameters:
other - an Object value
Returns:
true if the maps are identical

get

public Float get(Integer key)
Retrieves the value for key
Parameters:
key - an Object value
Returns:
the value of key or null if no such mapping exists.

getMap

public TIntFloatHashMap getMap()
Returns a reference to the map wrapped by this decorator.

isEmpty

public boolean isEmpty()
Indicates whether map has any entries.
Returns:
true if the map is empty

put

public Float put(Integer key,
                 Float value)
Inserts a key/value pair into the map.
Parameters:
key - an Object value
value - an Object value
Returns:
the previous value associated with key, or Float(0) if none was found.

putAll

public void putAll(extends Integer,
                   Float> map)
Copies the key/value mappings in map into this map. Note that this will be a deep copy, as storage is by primitive value.
Parameters:
map - a Map value

remove

public Float remove(Integer key)
Deletes a key/value pair from the map.
Parameters:
key - an Object value
Returns:
the removed value, or Float(0) if it was not found in the map

size

public int size()
Returns the number of entries in the map.
Returns:
the map's size.

unwrapKey

protected int unwrapKey(Object key)
Unwraps a key
Parameters:
key - wrapped key
Returns:
an unwrapped representation of the key

unwrapValue

protected float unwrapValue(Object value)
Unwraps a value
Parameters:
value - wrapped value
Returns:
an unwrapped representation of the value

wrapKey

protected Integer wrapKey(int k)
Wraps a key
Parameters:
k - key in the underlying map
Returns:
an Object representation of the key

wrapValue

protected Float wrapValue(float k)
Wraps a value
Parameters:
k - value in the underlying map
Returns:
an Object representation of the value

GNU Trove is copyright B) 2001-2007 Eric D. Friedman. All Rights Reserved.