public class OpenHashMap<K,V>
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, java.util.SortedMap<K,V>
| Modifier and Type | Class and Description |
|---|---|
static class |
OpenHashMap.AbstractObjectCollection<K> |
static class |
OpenHashMap.AbstractObjectSet<K> |
private class |
OpenHashMap.EntryIterator |
private class |
OpenHashMap.FastEntryIterator |
private class |
OpenHashMap.KeyIterator |
private class |
OpenHashMap.KeySet |
(package private) class |
OpenHashMap.MapEntry |
private class |
OpenHashMap.MapEntrySet |
private class |
OpenHashMap.MapIterator |
private class |
OpenHashMap.ValueIterator |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
containsNullKey |
protected V |
defRetValue |
protected java.util.SortedSet<java.util.Map.Entry<K,V>> |
entries |
protected float |
f |
protected java.lang.Iterable<java.util.Map.Entry<K,V>> |
fast |
protected int |
first |
protected java.lang.Object[] |
key |
protected java.util.SortedSet<K> |
keys |
protected int |
last |
protected long[] |
link |
protected int |
mask |
protected int |
maxFill |
protected int |
n |
private static long |
serialVersionUID |
protected int |
size |
protected java.lang.Object[] |
value |
protected java.util.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(java.util.Map<? extends K,? extends V> m) |
OpenHashMap(java.util.Map<? extends K,? extends V> m,
float f) |
| Modifier and Type | Method and Description |
|---|---|
private static int |
arraySize(int expected,
float f) |
private void |
checkTable() |
void |
clear() |
OpenHashMap<K,V> |
clone() |
java.util.Comparator<? super K> |
comparator() |
protected V |
compute(K k) |
boolean |
containsKey(java.lang.Object k) |
boolean |
containsValue(java.lang.Object v) |
V |
defaultReturnValue() |
void |
defaultReturnValue(V rv) |
private void |
ensureCapacity(int capacity) |
java.util.SortedSet<java.util.Map.Entry<K,V>> |
entrySet() |
boolean |
equals(java.lang.Object o) |
java.lang.Iterable<java.util.Map.Entry<K,V>> |
fast() |
K |
firstKey() |
protected void |
fixPointers(int i) |
protected void |
fixPointers(int s,
int d) |
V |
get(java.lang.Object k) |
V |
getAndMoveToFirst(K k) |
V |
getAndMoveToLast(K k) |
V |
getOrCompute(K k) |
int |
hashCode() |
java.util.SortedMap<K,V> |
headMap(K to) |
private int |
insert(K k,
V v) |
boolean |
isEmpty() |
java.util.SortedSet<K> |
keySet() |
K |
lastKey() |
private static int |
maxFill(int n,
float f) |
private static int |
mix(int x) |
private void |
moveIndexToFirst(int i) |
private void |
moveIndexToLast(int i) |
private static int |
nextPowerOfTwo(int x) |
private static long |
nextPowerOfTwo(long x) |
V |
put(K k,
V v) |
void |
putAll(java.util.Map<? extends K,? extends V> m) |
V |
putAndMoveToFirst(K k,
V v) |
V |
putAndMoveToLast(K k,
V v) |
private void |
readObject(java.io.ObjectInputStream s) |
private int |
realSize() |
protected void |
rehash(int newN)
Rehashes the map.
|
V |
remove(java.lang.Object k) |
private V |
removeEntry(int pos) |
V |
removeFirst() |
V |
removeLast() |
private V |
removeNullEntry() |
private V |
setValue(int pos,
V v) |
protected void |
shiftKeys(int pos) |
int |
size() |
java.util.SortedMap<K,V> |
subMap(K from,
K to) |
java.util.SortedMap<K,V> |
tailMap(K from) |
java.lang.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.
|
private void |
tryCapacity(long capacity) |
private static <K> int |
unwrap(java.util.Iterator<? extends K> i,
K[] array) |
private static <K> int |
unwrap(java.util.Iterator<? extends K> i,
K[] array,
int offset,
int max) |
java.util.Collection<V> |
values() |
private void |
writeObject(java.io.ObjectOutputStream s) |
private static final long serialVersionUID
protected transient java.lang.Object[] key
protected transient java.lang.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 java.util.SortedSet<K> keys
protected transient java.util.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(java.lang.Object o)
public java.lang.String toString()
toString in class java.lang.Objectprivate int realSize()
private void ensureCapacity(int capacity)
private void tryCapacity(long capacity)
private V removeEntry(int pos)
private V removeNullEntry()
protected final void shiftKeys(int pos)
public V removeFirst()
public V removeLast()
private void moveIndexToFirst(int i)
private void moveIndexToLast(int i)
public boolean containsKey(java.lang.Object k)
public boolean containsValue(java.lang.Object v)
protected void fixPointers(int i)
protected void fixPointers(int s,
int d)
public java.util.Comparator<? super K> comparator()
public java.util.SortedSet<K> keySet()
public java.util.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()
clone in class java.lang.Objectpublic int hashCode()
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException
java.io.IOExceptionprivate void readObject(java.io.ObjectInputStream s)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundExceptionprivate void checkTable()
private static int arraySize(int expected,
float f)
private static int maxFill(int n,
float f)
private static int nextPowerOfTwo(int x)
private static long nextPowerOfTwo(long x)
private static int mix(int x)
private static <K> int unwrap(java.util.Iterator<? extends K> i,
K[] array,
int offset,
int max)
private static <K> int unwrap(java.util.Iterator<? extends K> i,
K[] array)