Package fr.dyade.aaa.agent
Class ServersHT
- java.lang.Object
-
- fr.dyade.aaa.agent.ServersHT
-
public class ServersHT extends Object
This class implements a ServerDesc hashtable, which uses sid as keys.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classServersHT.EnumeratorA hashtable enumerator class.private static classServersHT.ServerDescEntryHashtable collision list.
-
Field Summary
Fields Modifier and Type Field Description private intcountThe total number of entries in the hash table.private static intinitialCapacityThe default initial capacity for the hashtable: 13.private static intKEYSprivate static floatloadFactorThe default load factor for the hashtable: 0.75f.private ServersHT.ServerDescEntry[]tableThe hash table data.private intthresholdThe table is rehashed each time its size exceeds this threshold.private static intVALUES
-
Constructor Summary
Constructors Constructor Description ServersHT()Constructs a new, empty hashtable with the default initial capacity and load factor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears this hashtable so that it contains no descriptors.Enumeration<ServerDesc>elements()Returns an enumeration of the server descriptors in this hashtable.ServerDescget(short sid)Returns the descriptor of the corresponding server.Enumeration<Short>keys()Returns an enumeration of the keys (server id.) in this hashtable.ServerDescput(ServerDesc desc)Maps the specifieddescin this hashtable.protected voidrehash()Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently.ServerDescremove(short sid)Removes the descriptor from this hashtable.intsize()Returns the number of entries in this hashtable.StringtoString()Returns a string representation of this Hashtable object.
-
-
-
Field Detail
-
table
private transient ServersHT.ServerDescEntry[] table
The hash table data.
-
count
private transient int count
The total number of entries in the hash table.
-
initialCapacity
private static final int initialCapacity
The default initial capacity for the hashtable: 13.- See Also:
- Constant Field Values
-
loadFactor
private static final float loadFactor
The default load factor for the hashtable: 0.75f.- See Also:
- Constant Field Values
-
threshold
private int threshold
The table is rehashed each time its size exceeds this threshold.
-
KEYS
private static final int KEYS
- See Also:
- Constant Field Values
-
VALUES
private static final int VALUES
- See Also:
- Constant Field Values
-
-
Method Detail
-
size
public int size()
Returns the number of entries in this hashtable.- Returns:
- the number of entries in this hashtable.
-
keys
public Enumeration<Short> keys()
Returns an enumeration of the keys (server id.) in this hashtable.- Returns:
- an enumeration of the keys in this hashtable.
- See Also:
Enumeration
-
elements
public Enumeration<ServerDesc> elements()
Returns an enumeration of the server descriptors in this hashtable. Use the Enumeration methods on the returned object to fetch the elements sequentially.- Returns:
- an enumeration of the values in this hashtable.
- See Also:
Enumeration
-
get
public ServerDesc get(short sid)
Returns the descriptor of the corresponding server.- Parameters:
sid- The server unique identification.- Returns:
- the descriptor of the corresponding server.
-
rehash
protected void rehash()
Increases the capacity of and internally reorganizes this hashtable, in order to accommodate and access its entries more efficiently. This method is called automatically when the number of keys in the hashtable exceeds this hashtable's capacity and load factor.
-
put
public ServerDesc put(ServerDesc desc)
Maps the specifieddescin this hashtable. The descriptor can be retrieved by calling thegetmethod with a key that is equal to the server id.- Parameters:
desc- the descriptor.- Returns:
- the previous value of the descriptor, or
nullif it did not have one. - Throws:
NullPointerException- if the descriptor isnull.
-
remove
public ServerDesc remove(short sid)
Removes the descriptor from this hashtable. This method does nothing if the key is not in the hashtable.- Parameters:
sid- the id of server that needs to be removed.- Returns:
- the descriptor of the server or
nullif it is not defined.
-
clear
public void clear()
Clears this hashtable so that it contains no descriptors.
-
-