org.apache.xerces.util

Class SymbolHash

public class SymbolHash extends Object

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

The hash code uses the same algorithm as SymbolTable class.

Version: $Id: SymbolHash.java,v 1.8 2004/02/24 23:15:53 mrglavas Exp $

Author: Elena Litani

Nested Class Summary
protected static classSymbolHash.Entry
This class is a key table entry.
Field Summary
protected SymbolHash.Entry[]fBuckets
Buckets.
protected intfNum
Number of elements.
protected intfTableSize
Default table size.
Constructor Summary
SymbolHash()
Constructs a key table with the default size.
SymbolHash(int size)
Constructs a key table with a given size.
Method Summary
voidclear()
Remove all key/value assocaition.
Objectget(Object key)
Get the value associated with the given key.
intgetLength()
Get the number of key/value pairs stored in this table.
intgetValues(Object[] elements, int from)
Add all values to the given array.
SymbolHashmakeClone()
Make a clone of this object.
voidput(Object key, Object value)
Adds the key/value mapping to the key table.
protected SymbolHash.Entrysearch(Object key, int bucket)

Field Detail

fBuckets

protected SymbolHash.Entry[] fBuckets
Buckets.

fNum

protected int fNum
Number of elements.

fTableSize

protected int fTableSize
Default table size.

Constructor Detail

SymbolHash

public SymbolHash()
Constructs a key table with the default size.

SymbolHash

public SymbolHash(int size)
Constructs a key table with a given size.

Parameters: size the size of the key table.

Method Detail

clear

public void clear()
Remove all key/value assocaition. This tries to save a bit of GC'ing by at least keeping the fBuckets array around.

get

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

Parameters: key

Returns: the value associated with the given key.

getLength

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

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

getValues

public int getValues(Object[] elements, int from)
Add all values to the given array. The array must have enough entry.

Parameters: elements the array to store the elements from where to start store element in the array

Returns: number of elements copied to the array

makeClone

public SymbolHash makeClone()
Make a clone of this object.

put

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.

Parameters: key value

search

protected SymbolHash.Entry search(Object key, int bucket)
Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.