APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.org.apache.xerces.internal.util

public Class SymbolHash

extends Object
Class Inheritance

This class is an unsynchronized hash table primary used for String to Object mapping.

The hash code uses the same algorithm as SymbolTable class.

Author
Elena Litani

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
SymbolHash.Entry

This class is a key table entry.

Field Summary

Modifier and TypeField and Description
protected SymbolHash.Entry[]
fBuckets

Buckets.

protected int[]
fHashMultipliers

Array of randomly selected hash function multipliers or null if the default String.hashCode() function should be used.

protected int
fNum

Number of elements.

protected int
fTableSize

Actual table size

protected static final int
MAX_HASH_COLLISIONS

Maximum hash collisions per bucket.

protected static final int
protected static final int
protected static final int
TABLE_SIZE

Default table size.

Constructor Summary

AccessConstructor and Description
public
SymbolHash()

Constructs a key table with the default size.

public
SymbolHash(int
the size of the key table.
size
)

Constructs a key table with a given size.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Remove all key/value association.

public Object

Returns:

the value associated with the given key.
get
(Object key)

Get the value associated with the given key.

public Object[]
getEntries()

Return key/value pairs of all entries in the map

public int

Returns:

the number of key/value pairs stored in this table.
getLength
()

Get the number of key/value pairs stored in this table.

public int

Returns:

number of elements copied to the array
getValues
(Object[]
the array to store the elements
elements
,
int
where to start store element in the array
from
)

Add all values to the given array.

protected int
hash(Object
The key to hash.
key
)

Returns a hashcode value for the specified key.

private int
hash0(String symbol)

public SymbolHash
makeClone()

Make a clone of this object.

public void
put(Object key, Object value)

Adds the key/value mapping to the key table.

protected void
rebalance()

Randomly selects a new hash function and reorganizes this SymbolHash in order to more evenly distribute its entries across the table.

protected void
rehash()

Increases the capacity of and internally reorganizes this SymbolHash, in order to accommodate and access its entries more efficiently.

private void
rehashCommon(final int newCapacity)

protected SymbolHash.Entry
search(Object key, int bucket)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fBucketsback to summary
protected SymbolHash.Entry[] fBuckets

Buckets.

fHashMultipliersback to summary
protected int[] fHashMultipliers

Array of randomly selected hash function multipliers or null if the default String.hashCode() function should be used.

fNumback to summary
protected int fNum

Number of elements.

fTableSizeback to summary
protected int fTableSize

Actual table size

MAX_HASH_COLLISIONSback to summary
protected static final int MAX_HASH_COLLISIONS

Maximum hash collisions per bucket.

MULTIPLIERS_MASKback to summary
protected static final int MULTIPLIERS_MASK
MULTIPLIERS_SIZEback to summary
protected static final int MULTIPLIERS_SIZE
TABLE_SIZEback to summary
protected static final int TABLE_SIZE

Default table size.

Constructor Detail

SymbolHashback to summary
public SymbolHash()

Constructs a key table with the default size.

SymbolHashback to summary
public SymbolHash(int size)

Constructs a key table with a given size.

Parameters
size:int

the size of the key table.

Method Detail

clearback to summary
public void clear()

Remove all key/value association. This tries to save a bit of GC'ing by at least keeping the fBuckets array around.

getback to summary
public Object get(Object key)

Get the value associated with the given key.

Returns:Object

the value associated with the given key.

getEntriesback to summary
public Object[] getEntries()

Return key/value pairs of all entries in the map

getLengthback to summary
public int getLength()

Get the number of key/value pairs stored in this table.

Returns:int

the number of key/value pairs stored in this table.

getValuesback to summary
public int getValues(Object[] elements, int from)

Add all values to the given array. The array must have enough entry.

Parameters
elements:Object[]

the array to store the elements

from:int

where to start store element in the array

Returns:int

number of elements copied to the array

hashback to summary
protected int hash(Object key)

Returns a hashcode value for the specified key.

Parameters
key:Object

The key to hash.

hash0back to summary
private int hash0(String symbol)
makeCloneback to summary
public SymbolHash makeClone()

Make a clone of this object.

putback to summary
public void put(Object key, Object value)

Adds the key/value mapping to the key table. If the key already exists, the previous value associated with this key is overwritten by the new value.

rebalanceback to summary
protected void rebalance()

Randomly selects a new hash function and reorganizes this SymbolHash in order to more evenly distribute its entries across the table. This method is called automatically when the number keys in one of the SymbolHash's buckets exceeds MAX_HASH_COLLISIONS.

rehashback to summary
protected void rehash()

Increases the capacity of and internally reorganizes this SymbolHash, in order to accommodate and access its entries more efficiently. This method is called automatically when the number of keys in the SymbolHash exceeds its number of buckets.

rehashCommonback to summary
private void rehashCommon(final int newCapacity)
searchback to summary
protected SymbolHash.Entry search(Object key, int bucket)
com.sun.org.apache.xerces.internal.util back to summary

protected final Class SymbolHash.Entry

extends Object
Class Inheritance

This class is a key table entry. Each entry acts as a node in a linked list.

Field Summary

Modifier and TypeField and Description
public Object
public SymbolHash.Entry
next

The next entry.

public Object

Constructor Summary

AccessConstructor and Description
public
public
Entry(Object key, Object value, SymbolHash.Entry next)

Method Summary

Modifier and TypeMethod and Description
public SymbolHash.Entry
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
public Object key
nextback to summary
public SymbolHash.Entry next

The next entry.

valueback to summary
public Object value

Constructor Detail

Entryback to summary
public Entry()
Entryback to summary
public Entry(Object key, Object value, SymbolHash.Entry next)

Method Detail

makeCloneback to summary
public SymbolHash.Entry makeClone()