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 onFastCopyHashMapby Jason T. Greene.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIntKeyMap.Entry<V>A map entry.
-
Field Summary
Fields Modifier and Type Field Description private static intDEFAULT_CAPACITYSame default as HashMap, must be a power of 2private static floatDEFAULT_LOAD_FACTOR67%, just like IdentityHashMapprivate floatloadFactorThe user defined load factor which defines when to resizeprivate static intMAXIMUM_CAPACITYMAX_INT - 1private static longserialVersionUIDprivate intsizeThe current number of key-value pairsprivate IntKeyMap.Entry<V>[]tableThe open-addressed tableprivate intthresholdThe next resize
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()IntKeyMap<V>clone()booleancontainsKey(int key)booleancontainsValue(java.lang.Object value)private static booleaneq(java.lang.Object o1, java.lang.Object o2)Vget(int key)private static intindex(int hashCode, int length)private voidinit(int initialCapacity, float loadFactor)booleanisEmpty()java.util.Iterator<IntKeyMap.Entry<V>>iterator()Iterate over the entries.private intnextIndex(int index, int length)voidprintDebugStats()Vput(int key, V value)private voidputForCreate(int key, V value)private voidreadObject(java.io.ObjectInputStream s)private voidrelocate(int start)Vremove(int key)private voidresize(int from)intsize()private voidwriteObject(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.IOExceptionjava.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:
iteratorin interfacejava.lang.Iterable<V>- Returns:
- the entry iterator
-
-