|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.util.LongHashtable
public class LongHashtable
This class implements a hashtable, which maps keys to values.
Any value can be used as a key.
A hashtable has two parameters that affect its efficiency: its
capacity and its load factor. The load factor should be
between 0.0 and 1.0. When the number of entries in the hashtable exceeds the
product of the load factor and the current capacity, the capacity is
increased by invoking LongHashtable.rehash()
. Larger load factors use memory more
efficiently, at the expense of larger expected time per lookup.
If many entries are to be made into a hashtable, creating it with a sufficiently large capacity may allow the entries to be inserted more efficiently than letting it perform automatic rehashing as needed to grow the table.
Constructor Summary | ||
---|---|---|
LongHashtable()
Construct a new, empty hashtable with a default capacity and load factor. |
||
LongHashtable(int initialCapacity)
Construct a new, empty hashtable with the specified capacity. |
||
LongHashtable(LongHashtable hashtable)
Construct a new hashtable based on the contents of the given hashtable. |
Method Summary | ||
---|---|---|
void |
clear()
Flush this hashtable. |
|
boolean |
contains(Object value)
Determines if some key maps into the specified value in this hashtable. |
|
boolean |
containsKey(long key)
Determines if the argument specified is a key in this hashtable. |
|
Enumeration |
elements()
Retrieves an enumeration of the values in this hashtable. |
|
Object |
get(long key)
Retrieves value by key. |
|
long |
getKey(Object obj)
Retrieves key by value. |
|
boolean |
isEmpty()
Determines if this hashtable maps no keys to values. |
|
LongEnumeration |
keys()
Retrieves an enumeration of the keys in this hashtable. |
|
int |
keysToArray(long[] array)
Extract keys into an array. |
|
Object |
put(long key,
Object value)
Maps value to key in this hashtable. |
|
protected void |
rehash()
Rehashes the contents of this hashtable. |
|
Object |
remove(long key)
Removes value by key. |
|
void |
resetElements(Enumeration e)
Resets an enumeration of the values in this hashtable as it would be after a call to LongHashtable.elements() . |
|
int |
size()
Retrieves the number of keys in this hashtable. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LongHashtable(int initialCapacity)
initialCapacity
- Initial capacity of the hashtable.
IllegalArgumentException
- If the initial capacity is less than
zeropublic LongHashtable()
public LongHashtable(LongHashtable hashtable)
The hashtable itself is copied, however, the references to the objects in the original hashtable are referred to by the new hashtable.
hashtable
- Source hashtable.Method Detail |
---|
public int size()
public boolean isEmpty()
public LongEnumeration keys()
Enumeration
,
LongHashtable.elements()
public Enumeration elements()
Use the Enumeration methods on the returned object to fetch the elements sequentially.
Enumeration
,
LongHashtable.keys()
public void resetElements(Enumeration e)
LongHashtable.elements()
.
e
- Enumeration in question.public boolean contains(Object value)
This operation is more expensive than LongHashtable.containsKey(long)
.
value
- Value to search for.
NullPointerException
- If null value provided.public boolean containsKey(long key)
key
- Key to test.
LongHashtable.contains(java.lang.Object)
public long getKey(Object obj)
Note: The use of this method is only valid if the element has been verified to be in the table.
obj
- Object to locate.
public void clear()
Invoke this method to remove all keys and values from this hashtable.
public Object remove(long key)
If the key does not exist in this hashtable, then this method does nothing.
key
- Key for value to remove.
public Object get(long key)
key
- Key in this hashtable.
protected void rehash()
Invoke this method to rehash this hashtable into one with a larger capacity. This hashtable invokes this method automatically when the number of keys exceeds its capacity and load factor.
public Object put(long key, Object value)
The value can be retrieved by invoking LongHashtable.get(long)
with a key that
is equal to the original key.
key
- Key to associate with the value.value
- Value to put into table.
NullPointerException
- If null key or null value.public int keysToArray(long[] array)
array
- Array to contain the keys; the array must be large enough to
contain all the keys.
ArrayIndexOutOfBoundsException
- If the array isn't big enough.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal