Package org.jboss.marshalling.util
Class IntKeyMap<V>
java.lang.Object
org.jboss.marshalling.util.IntKeyMap<V>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<IntKeyMap.Entry<V>>
public final class IntKeyMap<V>
extends Object
implements Cloneable, Serializable, Iterable<IntKeyMap.Entry<V>>
An integer-keyed map, optimized for fast copying. Based on
FastCopyHashMap
by Jason T. Greene.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
Same default as HashMap, must be a power of 2private static final float
67%, just like IdentityHashMapprivate final float
The user defined load factor which defines when to resizeprivate static final int
MAX_INT - 1private static final long
private int
The current number of key-value pairsprivate IntKeyMap.Entry<V>[]
The open-addressed tableprivate int
The next resize -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
clone()
boolean
containsKey
(int key) boolean
containsValue
(Object value) private static boolean
get
(int key) private static int
index
(int hashCode, int length) private void
init
(int initialCapacity, float loadFactor) boolean
isEmpty()
iterator()
Iterate over the entries.private int
nextIndex
(int index, int length) void
private void
putForCreate
(int key, V value) private void
private void
relocate
(int start) remove
(int key) private void
resize
(int from) int
size()
private void
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_CAPACITY
private static final int DEFAULT_CAPACITYSame default as HashMap, must be a power of 2- See Also:
-
MAXIMUM_CAPACITY
private static final int MAXIMUM_CAPACITYMAX_INT - 1- See Also:
-
DEFAULT_LOAD_FACTOR
private static final float DEFAULT_LOAD_FACTOR67%, just like IdentityHashMap- See Also:
-
table
The open-addressed table -
size
private transient int sizeThe current number of key-value pairs -
threshold
private transient int thresholdThe next resize -
loadFactor
private final float loadFactorThe user defined load factor which defines when to resize -
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
IntKeyMap
public IntKeyMap(int initialCapacity, float loadFactor) -
IntKeyMap
-
IntKeyMap
public IntKeyMap(int initialCapacity) -
IntKeyMap
public IntKeyMap()
-
-
Method Details
-
init
private void init(int initialCapacity, float loadFactor) -
nextIndex
private int nextIndex(int index, int length) -
eq
-
index
private static int index(int hashCode, int length) -
size
public int size() -
isEmpty
public boolean isEmpty() -
get
-
containsKey
public boolean containsKey(int key) -
containsValue
-
put
-
resize
private void resize(int from) -
remove
-
relocate
private void relocate(int start) -
clear
public void clear() -
clone
-
printDebugStats
public void printDebugStats() -
readObject
- Throws:
IOException
ClassNotFoundException
-
putForCreate
-
writeObject
- Throws:
IOException
-
iterator
Iterate over the entries. Read-only operation.
-