j3d.org Code

org.j3d.util
Class FloatHashMap

java.lang.Object
  extended by org.j3d.util.FloatHashMap

public class FloatHashMap
extends java.lang.Object

A hash map that uses primitive doubles for the key rather than objects.

Version:
$Revision: 1.2 $
Author:
Georg Rehfeld

Constructor Summary
FloatHashMap()
          Constructs a new, empty hashtable with a default capacity and load factor, which is 20 and 0.75 respectively.
FloatHashMap(int initialCapacity)
          Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75.
FloatHashMap(int initialCapacity, float loadFactor)
          Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.
 
Method Summary
 void clear()
          Clears this hashtable so that it contains no keys.
 boolean contains(java.lang.Object value)
          Tests if some key maps into the specified value in this hashtable.
 boolean containsKey(float key)
          Tests if the specified object is a key in this hashtable.
 boolean containsValue(java.lang.Object value)
          Returns true if this HashMap maps one or more keys to this value.
 java.lang.Object get(float key)
          Returns the value to which the specified key is mapped in this map.
 boolean isEmpty()
          Tests if this hashtable maps no keys to values.
 float[] keySet()
          Returns an array with all keys.
 float[] keySetSorted()
          Returns a sorted array with all keys.
 java.lang.Object put(float key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object remove(float key)
          Removes the key (and its corresponding value) from this hashtable.
 int size()
          Returns the number of keys in this hashtable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FloatHashMap

public FloatHashMap()
Constructs a new, empty hashtable with a default capacity and load factor, which is 20 and 0.75 respectively.


FloatHashMap

public FloatHashMap(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75.

Parameters:
initialCapacity - the initial capacity of the hashtable.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero.

FloatHashMap

public FloatHashMap(int initialCapacity,
                    float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.

Parameters:
initialCapacity - the initial capacity of the hashtable.
loadFactor - the load factor of the hashtable.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.
Method Detail

size

public int size()
Returns the number of keys in this hashtable.

Returns:
the number of keys in this hashtable.

isEmpty

public boolean isEmpty()
Tests if this hashtable maps no keys to values.

Returns:
true if this hashtable maps no keys to values; false otherwise.

contains

public boolean contains(java.lang.Object value)
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).

Parameters:
value - a value to search for.
Returns:
true if and only if some key maps to the value argument in this hashtable as determined by the equals method; false otherwise.
Throws:
java.lang.NullPointerException - if the value is null.
See Also:
Map

containsValue

public boolean containsValue(java.lang.Object value)
Returns true if this HashMap maps one or more keys to this value.

Note that this method is identical in functionality to contains (which predates the Map interface).

Parameters:
value - value whose presence in this HashMap is to be tested.
Since:
JDK1.2
See Also:
Map

containsKey

public boolean containsKey(float key)
Tests if the specified object is a key in this hashtable.

Parameters:
key - possible key.
Returns:
true if and only if the specified object is a key in this hashtable, as determined by the equals method; false otherwise.
See Also:
contains(Object)

get

public java.lang.Object get(float key)
Returns the value to which the specified key is mapped in this map.

Parameters:
key - a key in the hashtable.
Returns:
the value to which the key is mapped in this hashtable; null if the key is not mapped to any value in this hashtable.

put

public java.lang.Object put(float key,
                            java.lang.Object value)
Maps the specified key to the specified value in this hashtable. The key cannot be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters:
key - the hashtable key.
value - the value.
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one.
See Also:
get(float)

remove

public java.lang.Object remove(float key)
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable.

Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

clear

public void clear()
Clears this hashtable so that it contains no keys.


keySet

public float[] keySet()
Returns an array with all keys. The order of keys is unspecified.

Returns:
the array with the keys

keySetSorted

public float[] keySetSorted()
Returns a sorted array with all keys. The keys are sorted ascending.

Returns:
the sorted array with the keys

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org