public final class ObjectOpenHashMap<K,V>
extends java.lang.Object
A type-specific hash map with a fast, small-footprint implementation.
Instances of this class use a hash table to represent a map. The table is filled up to a specified load factor, and then doubled in size to accommodate new entries. If the table is emptied below one fourth of the load factor, it is halved in size; however, the table is never reduced to a size smaller than that at creation time: this approach makes it possible to create maps with a large capacity in which insertions and deletions do not cause immediately rehashing. Moreover, halving is not performed when deleting entries from an iterator, as it would interfere with the iteration process.
HashCommon
,
fastutilConstructor and Description |
---|
ObjectOpenHashMap()
Creates a new hash map with initial expected
DEFAULT_INITIAL_SIZE entries and DEFAULT_LOAD_FACTOR as load factor. |
ObjectOpenHashMap(int expected)
Creates a new hash map with
DEFAULT_LOAD_FACTOR as load factor. |
ObjectOpenHashMap(int expected,
float f)
Creates a new hash map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object k) |
V |
get(java.lang.Object k) |
int |
hashCode()
Returns a hash code for this map.
|
boolean |
isEmpty() |
V |
put(K k,
V v) |
V |
remove(java.lang.Object k) |
int |
size() |
public ObjectOpenHashMap(int expected, float f)
The actual table size will be the least power of two greater than expected
/f
.
expected
- the expected number of elements in the hash map.f
- the load factor.public ObjectOpenHashMap(int expected)
DEFAULT_LOAD_FACTOR
as load factor.expected
- the expected number of elements in the hash map.public ObjectOpenHashMap()
DEFAULT_INITIAL_SIZE
entries and DEFAULT_LOAD_FACTOR
as load factor.public V get(java.lang.Object k)
public boolean containsKey(java.lang.Object k)
public V remove(java.lang.Object k)
public void clear()
public int size()
public boolean isEmpty()
public int hashCode()
This method overrides the generic method provided by the superclass. Since equals()
is not overriden, it is important that the value returned by this method is the same value as
the one returned by the overriden method.
hashCode
in class java.lang.Object
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.