public class LongHashtable extends Object implements Cloneable
A hash map that uses primitive ints for the key rather than objects.
Note that this class is for internal optimization purposes only, and may not be supported in future releases of Jakarta Commons Lang. Utilities of this sort may be included in future releases of Jakarta Commons Collections.
Constructor and Description |
---|
LongHashtable()
Constructs a new, empty hashtable with a default capacity and load factor, which is 20 and 0.75 respectively.
|
LongHashtable(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75 .
|
LongHashtable(int initialCapacity, float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this hashtable so that it contains no keys.
|
Object |
clone() |
boolean |
contains(long value)
Tests if some key maps into the specified value in this hashtable.
|
boolean |
containsKey(long key)
Tests if the specified int is a key in this hashtable.
|
boolean |
containsValue(long value)
Returns true if this HashMap maps one or more keys to this value.
|
long |
get(long key)
Returns the value to which the specified key is mapped in this map.
|
Iterator |
getEntryIterator() |
long[] |
getKeys() |
long |
getOneKey() |
boolean |
isEmpty()
Tests if this hashtable maps no keys to values.
|
long |
put(long key, long value)
Maps the specified key to the specified value in this hashtable.
|
protected void |
rehash()
Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.
|
long |
remove(long key)
Removes the key (and its corresponding value) from this hashtable.
|
int |
size()
Returns the number of keys in this hashtable.
|
long[] |
toOrderedKeys() |
public LongHashtable()
Constructs a new, empty hashtable with a default capacity and load factor, which is 20
and 0.75
respectively.
public LongHashtable(int initialCapacity)
Constructs a new, empty hashtable with the specified initial capacity and default load factor, which is 0.75
.
initialCapacity
- the initial capacity of the hashtable.
IllegalArgumentException
- if the initial capacity is less than zero.
public LongHashtable(int initialCapacity, float loadFactor)
Constructs a new, empty hashtable with the specified initial capacity and the specified load factor.
initialCapacity
- the initial capacity of the hashtable.
loadFactor
- the load factor of the hashtable.
IllegalArgumentException
- if the initial capacity is less than zero, or if the load factor is nonpositive.
public int size()
Returns the number of keys in this hashtable.
public boolean isEmpty()
Tests if this hashtable maps no keys to values.
true
if this hashtable maps no keys to values; false
otherwise.
public boolean contains(long 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).
value
- a value to search for.
true
if and only if some key maps to the value
argument in this hashtable as determined by the equals method; false
otherwise.
NullPointerException
- if the value is null
.
#containsKey(int)
, #containsValue(int)
, Map
public boolean containsValue(long 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).
value
- value whose presence in this HashMap is to be tested.
true
if the value is contained
Map
public boolean containsKey(long key)
Tests if the specified int is a key in this hashtable.
key
- possible key.
true
if and only if the specified int is a key in this hashtable, as determined by the equals method; false
otherwise.
#contains(int)
public long get(long key)
Returns the value to which the specified key is mapped in this map.
key
- a key in the hashtable.
null
if the key is not mapped to any value in this hashtable.
#put(int, int)
protected void rehash()
Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.
This method is called automatically when the number of keys in the hashtable exceeds this hashtable's capacity and load factor.
public long put(long key, long 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.
key
- the hashtable key.
value
- the value.
null
if it did not have one.
NullPointerException
- if the key is null
.
#get(int)
public long remove(long key)
Removes the key (and its corresponding value) from this hashtable.
This method does nothing if the key is not present in the hashtable.
key
- the key that needs to be removed.
null
if the key did not have a mapping.
public void clear()
Clears this hashtable so that it contains no keys.
public IteratorgetEntryIterator()
public long[] toOrderedKeys()
public long[] getKeys()
public long getOneKey()
Copyright © 1998–2022. All rights reserved.