org.apache.batik.dom.util

Class HashTable

public class HashTable extends Object implements Serializable

A simple hashtable, not synchronized, with fixed load factor.
Nested Class Summary
protected static classHashTable.Entry
To manage collisions
Field Summary
protected intcount
The number of entries
protected static intINITIAL_CAPACITY
The initial capacity
protected HashTable.Entry[]table
The underlying array
Constructor Summary
HashTable()
Creates a new table.
HashTable(int c)
Creates a new table.
HashTable(HashTable t)
Creates a copy of the given HashTable object.
Method Summary
voidclear()
Clears the map.
Objectget(Object key)
Gets the value of a variable
Objectitem(int index)
Returns the item at the given position.
Objectkey(int index)
Returns the key at the given position or null.
Objectput(Object key, Object value)
Sets a new value for the given variable
protected voidrehash()
Rehash the table
Objectremove(Object key)
Removes an entry from the table.
intsize()
Returns the size of this table.

Field Detail

count

protected int count
The number of entries

INITIAL_CAPACITY

protected static final int INITIAL_CAPACITY
The initial capacity

table

protected HashTable.Entry[] table
The underlying array

Constructor Detail

HashTable

public HashTable()
Creates a new table.

HashTable

public HashTable(int c)
Creates a new table.

Parameters: c The initial capacity.

HashTable

public HashTable(HashTable t)
Creates a copy of the given HashTable object.

Parameters: t The table to copy.

Method Detail

clear

public void clear()
Clears the map.

get

public Object get(Object key)
Gets the value of a variable

Returns: the value or null

item

public Object item(int index)
Returns the item at the given position.

key

public Object key(int index)
Returns the key at the given position or null.

put

public Object put(Object key, Object value)
Sets a new value for the given variable

Returns: the old value or null

rehash

protected void rehash()
Rehash the table

remove

public Object remove(Object key)
Removes an entry from the table.

Returns: the value or null.

size

public int size()
Returns the size of this table.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.