gnu.trove.decorator

Class TDoubleIntHashMapDecorator

Implemented Interfaces:
Cloneable, Map

public class TDoubleIntHashMapDecorator
extends AbstractMap
implements Map, Cloneable

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

Constructor Summary

TDoubleIntHashMapDecorator(TDoubleIntHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Summary

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

Field Details

_map

protected TDoubleIntHashMap _map
the wrapped primitive map

Constructor Details

TDoubleIntHashMapDecorator

public TDoubleIntHashMapDecorator(TDoubleIntHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Details

clear

public void clear()
Empties the map.

clone

public TDoubleIntHashMapDecorator 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 Integer get(Double 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 TDoubleIntHashMap 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 Integer put(Double key,
                   Integer 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 Integer(0) if none was found.

putAll

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

unwrapValue

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

wrapKey

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

wrapValue

protected Integer wrapValue(int 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.