public class OpenHashMap<K,V> extends Object implements Serializable, Cloneable, SortedMap<K,V>
Modifier and Type | Class and Description |
---|---|
static class |
OpenHashMap.AbstractObjectCollection<K> |
static class |
OpenHashMap.AbstractObjectSet<K> |
Modifier and Type | Field and Description |
---|---|
protected boolean |
containsNullKey |
protected V |
defRetValue |
protected SortedSet<Map.Entry<K,V>> |
entries |
protected float |
f |
protected Iterable<Map.Entry<K,V>> |
fast |
protected int |
first |
protected Object[] |
key |
protected SortedSet<K> |
keys |
protected int |
last |
protected long[] |
link |
protected int |
mask |
protected int |
maxFill |
protected int |
n |
protected int |
size |
protected Object[] |
value |
protected Collection<V> |
values |
Constructor and Description |
---|
OpenHashMap() |
OpenHashMap(int expected) |
OpenHashMap(int expected,
float f) |
OpenHashMap(K[] k,
V[] v) |
OpenHashMap(K[] k,
V[] v,
float f) |
OpenHashMap(Map<? extends K,? extends V> m) |
OpenHashMap(Map<? extends K,? extends V> m,
float f) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
OpenHashMap<K,V> |
clone() |
Comparator<? super K> |
comparator() |
protected V |
compute(K k) |
boolean |
containsKey(Object k) |
boolean |
containsValue(Object v) |
V |
defaultReturnValue() |
void |
defaultReturnValue(V rv) |
SortedSet<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object o) |
Iterable<Map.Entry<K,V>> |
fast() |
K |
firstKey() |
protected void |
fixPointers(int i) |
protected void |
fixPointers(int s,
int d) |
V |
get(Object k) |
V |
getAndMoveToFirst(K k) |
V |
getAndMoveToLast(K k) |
V |
getOrCompute(K k) |
int |
hashCode() |
SortedMap<K,V> |
headMap(K to) |
boolean |
isEmpty() |
SortedSet<K> |
keySet() |
K |
lastKey() |
V |
put(K k,
V v) |
void |
putAll(Map<? extends K,? extends V> m) |
V |
putAndMoveToFirst(K k,
V v) |
V |
putAndMoveToLast(K k,
V v) |
protected void |
rehash(int newN)
Rehashes the map.
|
V |
remove(Object k) |
V |
removeFirst() |
V |
removeLast() |
protected void |
shiftKeys(int pos) |
int |
size() |
SortedMap<K,V> |
subMap(K from,
K to) |
SortedMap<K,V> |
tailMap(K from) |
String |
toString() |
boolean |
trim()
Rehashes the map, making the table as small as possible.
|
boolean |
trim(int n)
Rehashes this map if the table is too large.
|
Collection<V> |
values() |
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
protected transient Object[] key
protected transient Object[] value
protected transient int mask
protected transient boolean containsNullKey
protected transient int first
protected transient int last
protected transient long[] link
protected transient int n
protected transient int maxFill
protected int size
protected final float f
protected V defRetValue
protected transient Collection<V> values
public OpenHashMap(int expected, float f)
public OpenHashMap(int expected)
public OpenHashMap()
public void defaultReturnValue(V rv)
public V defaultReturnValue()
public boolean equals(Object o)
protected final void shiftKeys(int pos)
public V removeFirst()
public V removeLast()
public boolean containsKey(Object k)
containsKey
in interface Map<K,V>
public boolean containsValue(Object v)
containsValue
in interface Map<K,V>
protected void fixPointers(int i)
protected void fixPointers(int s, int d)
public Comparator<? super K> comparator()
comparator
in interface SortedMap<K,V>
public Collection<V> values()
public boolean trim()
This method rehashes the table to the smallest size satisfying the load factor. It can be used when the set will not be changed anymore, so to optimize access speed and size.
If the table size is already the minimum possible, this method does nothing.
trim(int)
public boolean trim(int n)
Let N be the smallest table size that can hold
max(n,
entries, still satisfying the load factor. If the current
table size is smaller than or equal to N, this method does
nothing. Otherwise, it rehashes this map in a table of size
N.
size()
)
This method is useful when reusing maps. Clearing a map leaves the table size untouched. If you are reusing a map many times, you can call this method with a typical size to avoid keeping around a very large table just because of a few large transient maps.
n
- the threshold for the trimming.trim()
protected void rehash(int newN)
This method implements the basic rehashing strategy, and may be overriden by subclasses implementing different rehashing strategies (e.g., disk-based rehashing). However, you should not override this method unless you understand the internal workings of this class.
newN
- the new sizepublic OpenHashMap<K,V> clone()
Copyright © 2006–2019 The Apache Software Foundation. All rights reserved.