gnu.trove.decorator

Class TIntLongHashMapDecorator

Implemented Interfaces:
Cloneable, Map

public class TIntLongHashMapDecorator
extends AbstractMap
implements Map, Cloneable

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

Constructor Summary

TIntLongHashMapDecorator(TIntLongHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Summary

void
clear()
Empties the map.
TIntLongHashMapDecorator
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.
Long
get(Integer key)
Retrieves the value for key
TIntLongHashMap
getMap()
Returns a reference to the map wrapped by this decorator.
boolean
isEmpty()
Indicates whether map has any entries.
Long
put(Integer key, Long value)
Inserts a key/value pair into the map.
void
putAll(extends Integer, Long> map)
Copies the key/value mappings in map into this map.
Long
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 long
unwrapValue(Object value)
Unwraps a value
protected Integer
wrapKey(int k)
Wraps a key
protected Long
wrapValue(long k)
Wraps a value

Field Details

_map

protected TIntLongHashMap _map
the wrapped primitive map

Constructor Details

TIntLongHashMapDecorator

public TIntLongHashMapDecorator(TIntLongHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Details

clear

public void clear()
Empties the map.

clone

public TIntLongHashMapDecorator 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 Long 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 TIntLongHashMap 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 Long put(Integer key,
                Long 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 Long(0) if none was found.

putAll

public void putAll(extends Integer,
                   Long> 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 Long remove(Integer key)
Deletes a key/value pair from the map.
Parameters:
key - an Object value
Returns:
the removed value, or Long(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 long 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 Long wrapValue(long 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.