/***************************************************************************** * J3D.org Copyright (c) 2001 * Java Source * * This source is licensed under the GNU LGPL v2.1 * Please read http://www.gnu.org/copyleft/lgpl.html for more information * * This software comes with the standard NO WARRANTY disclaimer for any * purpose. Use it at your own risk. If there's a problem you get to fix it. * ****************************************************************************/ package org.j3d.util; // Standard imports import java.util.Arrays; import java.util.ArrayList; // Application specific imports // None /** * A hash map that uses primitive longs for the key rather than objects. *
* * This implementation is not thread-safe, so caution must be exercised about how * items are added and removed from the instance. *
* Internationalisation Resource Names *
*
true if this hashtable maps no keys to values;
* false otherwise.
*/
public boolean isEmpty()
{
return count == 0;
}
/**
* Tests if some key maps into the specified value in this hashtable.
* This operation is more expensive than the containsKey
* method.
*
* Note that this method is identical in functionality to containsValue,
* (which is part of the Map interface in the collections framework).
*
* @param value a value to search for.
* @return
*
* Note that this method is identical in functionality to contains
* (which predates the Map interface).
*
* @param value value whose presence in this HashMap is to be tested.
* @see java.util.Map
* @since JDK1.2
*/
public boolean containsValue(V value)
{
return contains(value);
}
/**
* Tests if the specified object is a key in this hashtable.
*
* @param key possible key.
* @return
*
* The value can be retrieved by calling the true if and only if some key maps to the
* value argument in this hashtable as determined by the
* equals method; false otherwise.
* @throws NullPointerException if the value is null.
* @see #containsKey(int)
* @see #containsValue(Object)
* @see java.util.Map
*/
public boolean contains(V value)
{
if(value == null)
{
I18nManager intl_mgr = I18nManager.getManager();
String msg = intl_mgr.getString(NO_VALUE_ERR_PROP);
throw new NullPointerException(msg);
}
Entrytrue if and only if the specified object is a
* key in this hashtable, as determined by the equals
* method; false otherwise.
* @see #contains(Object)
*/
public boolean containsKey(long key)
{
Entry tab[] = table;
long hash = key;
int index = (int)((hash & 0x7FFFFFFF) % tab.length);
for(Entry e = tab[index] ; e != null ; e = e.next)
{
if(e.hash == hash)
return true;
}
return false;
}
/**
* Returns the value to which the specified key is mapped in this map.
*
* @param key a key in the hashtable.
* @return the value to which the key is mapped in this hashtable;
* null if the key is not mapped to any value in
* this hashtable.
* @see #put(int, Object)
*/
public V get(long key)
{
Entrykey to the specified
* value in this hashtable. The key cannot be
* null. get method
* with a key that is equal to the original key.
*
* @param key the hashtable key.
* @param value the value.
* @return the previous value of the specified key in this hashtable,
* or null if it did not have one.
* @throws NullPointerException if the key is null.
* @see #get(int)
*/
public V put(long key, V value)
{
// Makes sure the key is not already in the hashtable.
Entrynull if the key did not have a mapping.
*/
public V remove(int key)
{
Entry