Package org.jboss.marshalling.util
Class IntKeyMap<V>
- java.lang.Object
-
- org.jboss.marshalling.util.IntKeyMap<V>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<IntKeyMap.Entry<V>>
public final class IntKeyMap<V> extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, java.lang.Iterable<IntKeyMap.Entry<V>>
An integer-keyed map, optimized for fast copying. Based onFastCopyHashMap
by Jason T. Greene.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IntKeyMap.Entry<V>
A map entry.
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_CAPACITY
Same default as HashMap, must be a power of 2private static float
DEFAULT_LOAD_FACTOR
67%, just like IdentityHashMapprivate float
loadFactor
The user defined load factor which defines when to resizeprivate static int
MAXIMUM_CAPACITY
MAX_INT - 1private static long
serialVersionUID
private int
size
The current number of key-value pairsprivate IntKeyMap.Entry<V>[]
table
The open-addressed tableprivate int
threshold
The next resize
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
IntKeyMap<V>
clone()
boolean
containsKey(int key)
boolean
containsValue(java.lang.Object value)
private static boolean
eq(java.lang.Object o1, java.lang.Object o2)
V
get(int key)
private static int
index(int hashCode, int length)
private void
init(int initialCapacity, float loadFactor)
boolean
isEmpty()
java.util.Iterator<IntKeyMap.Entry<V>>
iterator()
Iterate over the entries.private int
nextIndex(int index, int length)
void
printDebugStats()
V
put(int key, V value)
private void
putForCreate(int key, V value)
private void
readObject(java.io.ObjectInputStream s)
private void
relocate(int start)
V
remove(int key)
private void
resize(int from)
int
size()
private void
writeObject(java.io.ObjectOutputStream s)
-
-
-
Field Detail
-
DEFAULT_CAPACITY
private static final int DEFAULT_CAPACITY
Same default as HashMap, must be a power of 2- See Also:
- Constant Field Values
-
MAXIMUM_CAPACITY
private static final int MAXIMUM_CAPACITY
MAX_INT - 1- See Also:
- Constant Field Values
-
DEFAULT_LOAD_FACTOR
private static final float DEFAULT_LOAD_FACTOR
67%, just like IdentityHashMap- See Also:
- Constant Field Values
-
table
private transient IntKeyMap.Entry<V>[] table
The open-addressed table
-
size
private transient int size
The current number of key-value pairs
-
threshold
private transient int threshold
The next resize
-
loadFactor
private final float loadFactor
The user defined load factor which defines when to resize
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
private void init(int initialCapacity, float loadFactor)
-
nextIndex
private int nextIndex(int index, int length)
-
eq
private static boolean eq(java.lang.Object o1, java.lang.Object o2)
-
index
private static int index(int hashCode, int length)
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
get
public V get(int key)
-
containsKey
public boolean containsKey(int key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
resize
private void resize(int from)
-
remove
public V remove(int key)
-
relocate
private void relocate(int start)
-
clear
public void clear()
-
printDebugStats
public void printDebugStats()
-
readObject
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
putForCreate
private void putForCreate(int key, V value)
-
writeObject
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException
- Throws:
java.io.IOException
-
iterator
public java.util.Iterator<IntKeyMap.Entry<V>> iterator()
Iterate over the entries. Read-only operation.- Specified by:
iterator
in interfacejava.lang.Iterable<V>
- Returns:
- the entry iterator
-
-