Top Description Inners Fields Constructors Methods
org.jboss.marshalling.util

public final Class IntKeyMap<V>

extends Object
implements Cloneable, Serializable, Iterable<IntKeyMap.Entry<V>>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable, java.io.Serializable, java.lang.Cloneable
Imports
java.io.IOException, .Serializable, java.util.Iterator, .NoSuchElementException

An integer-keyed map, optimized for fast copying. Based on FastCopyHashMap by Jason T. Greene.
Authors
Jason T. Greene, David M. Lloyd

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
IntKeyMap.Entry<
the value type
V
>

A map entry.

Field Summary

Modifier and TypeField and Description
private static final int
DEFAULT_CAPACITY

Same default as HashMap, must be a power of 2

private static final float
DEFAULT_LOAD_FACTOR

67%, just like IdentityHashMap

private final float
loadFactor

The user defined load factor which defines when to resize

private static final int
MAXIMUM_CAPACITY

MAX_INT - 1

private static final long
private transient int
size

The current number of key-value pairs

private transient IntKeyMap.Entry<V>[]
table

The open-addressed table

private transient int
threshold

The next resize

Constructor Summary

AccessConstructor and Description
public
IntKeyMap(int initialCapacity, float loadFactor)

public
IntKeyMap(IntKeyMap<? extends V> map)

public
IntKeyMap(int initialCapacity)

public

Method Summary

Modifier and TypeMethod and Description
public void
public IntKeyMap<V>
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public boolean
containsKey(int key)

public boolean
private static boolean
eq(Object o1, Object o2)

public V
get(int key)

private static int
index(int hashCode, int length)

private void
init(int initialCapacity, float loadFactor)

public boolean
public Iterator<IntKeyMap.Entry<V>>

Returns:

the entry iterator
iterator
()

Implements java.lang.Iterable.iterator.

Iterate over the entries.
private int
nextIndex(int index, int length)

public void
public V
put(int key, V value)

private void
putForCreate(int key, V value)

private void
private void
relocate(int start)

public V
remove(int key)

private void
resize(int from)

public int
size()

private void
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_CAPACITYback to summary
private static final int DEFAULT_CAPACITY

Same default as HashMap, must be a power of 2

DEFAULT_LOAD_FACTORback to summary
private static final float DEFAULT_LOAD_FACTOR

67%, just like IdentityHashMap

loadFactorback to summary
private final float loadFactor

The user defined load factor which defines when to resize

MAXIMUM_CAPACITYback to summary
private static final int MAXIMUM_CAPACITY

MAX_INT - 1

serialVersionUIDback to summary
private static final long serialVersionUID
sizeback to summary
private transient int size

The current number of key-value pairs

tableback to summary
private transient IntKeyMap.Entry<V>[] table

The open-addressed table

thresholdback to summary
private transient int threshold

The next resize

Constructor Detail

IntKeyMapback to summary
public IntKeyMap(int initialCapacity, float loadFactor)
IntKeyMapback to summary
public IntKeyMap(IntKeyMap<? extends V> map)
Annotations
@SuppressWarnings:unchecked
IntKeyMapback to summary
public IntKeyMap(int initialCapacity)
IntKeyMapback to summary
public IntKeyMap()

Method Detail

clearback to summary
public void clear()
cloneback to summary
public IntKeyMap<V> clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:IntKeyMap<V>

a clone of this instance.

Annotations
@SuppressWarnings:unchecked
containsKeyback to summary
public boolean containsKey(int key)
containsValueback to summary
public boolean containsValue(Object value)
eqback to summary
private static boolean eq(Object o1, Object o2)
getback to summary
public V get(int key)
indexback to summary
private static int index(int hashCode, int length)
initback to summary
private void init(int initialCapacity, float loadFactor)
Annotations
@SuppressWarnings:unchecked
isEmptyback to summary
public boolean isEmpty()
iteratorback to summary
public Iterator<IntKeyMap.Entry<V>> iterator()

Implements java.lang.Iterable.iterator.

Iterate over the entries. Read-only operation.

Returns:Iterator<IntKeyMap.Entry<V>>

the entry iterator

nextIndexback to summary
private int nextIndex(int index, int length)
printDebugStatsback to summary
public void printDebugStats()
putback to summary
public V put(int key, V value)
putForCreateback to summary
private void putForCreate(int key, V value)
Annotations
@SuppressWarnings:unchecked
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
Annotations
@SuppressWarnings:unchecked
relocateback to summary
private void relocate(int start)
removeback to summary
public V remove(int key)
resizeback to summary
private void resize(int from)
Annotations
@SuppressWarnings:unchecked
sizeback to summary
public int size()
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException
org.jboss.marshalling.util back to summary

public final Class IntKeyMap.Entry<V>

extends Object
Class Inheritance
Type Parameters
<V>
the value type

A map entry.

Field Summary

Modifier and TypeField and Description
private final int
private final V

Constructor Summary

AccessConstructor and Description
private
Entry(int key, V value)

Method Summary

Modifier and TypeMethod and Description
public int
public V
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
private final int key
valueback to summary
private final V value

Constructor Detail

Entryback to summary
private Entry(int key, V value)

Method Detail

getKeyback to summary
public int getKey()
getValueback to summary
public V getValue()