gnu.trove.decorator

Class TShortByteHashMapDecorator

Implemented Interfaces:
Cloneable, Map

public class TShortByteHashMapDecorator
extends AbstractMap
implements Map, Cloneable

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

Constructor Summary

TShortByteHashMapDecorator(TShortByteHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Summary

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

Field Details

_map

protected TShortByteHashMap _map
the wrapped primitive map

Constructor Details

TShortByteHashMapDecorator

public TShortByteHashMapDecorator(TShortByteHashMap map)
Creates a wrapper that decorates the specified primitive map.

Method Details

clear

public void clear()
Empties the map.

clone

public TShortByteHashMapDecorator 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 Byte get(Short 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 TShortByteHashMap 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 Byte put(Short key,
                Byte 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 Byte(0) if none was found.

putAll

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

unwrapValue

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

wrapKey

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

wrapValue

protected Byte wrapValue(byte 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.