gnu.trove.decorator

Class TFloatDoubleHashMapDecorator

Implemented Interfaces:
Cloneable, Map

public class TFloatDoubleHashMapDecorator
extends AbstractMap
implements Map, Cloneable

Wrapper class to make a TFloatDoubleHashMap conform to the java.util.Map API. This class simply decorates an underlying TFloatDoubleHashMap 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 TFloatDoubleHashMap
_map
the wrapped primitive map

Constructor Summary

TFloatDoubleHashMapDecorator(TFloatDoubleHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Summary

void
clear()
Empties the map.
TFloatDoubleHashMapDecorator
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.
Double
get(Float key)
Retrieves the value for key
TFloatDoubleHashMap
getMap()
Returns a reference to the map wrapped by this decorator.
boolean
isEmpty()
Indicates whether map has any entries.
Double
put(Float key, Double value)
Inserts a key/value pair into the map.
void
putAll(extends Float, Double> map)
Copies the key/value mappings in map into this map.
Double
remove(Float key)
Deletes a key/value pair from the map.
int
size()
Returns the number of entries in the map.
protected float
unwrapKey(Object key)
Unwraps a key
protected double
unwrapValue(Object value)
Unwraps a value
protected Float
wrapKey(float k)
Wraps a key
protected Double
wrapValue(double k)
Wraps a value

Field Details

_map

protected TFloatDoubleHashMap _map
the wrapped primitive map

Constructor Details

TFloatDoubleHashMapDecorator

public TFloatDoubleHashMapDecorator(TFloatDoubleHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Details

clear

public void clear()
Empties the map.

clone

public TFloatDoubleHashMapDecorator 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 Double get(Float 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 TFloatDoubleHashMap 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 Double put(Float key,
                  Double 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 Double(0) if none was found.

putAll

public void putAll(extends Float,
                   Double> 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 Double remove(Float key)
Deletes a key/value pair from the map.
Parameters:
key - an Object value
Returns:
the removed value, or Double(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 float unwrapKey(Object key)
Unwraps a key
Parameters:
key - wrapped key
Returns:
an unwrapped representation of the key

unwrapValue

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

wrapKey

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

wrapValue

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

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