public class ServersHT extends Object
Modifier and Type | Class and Description |
---|---|
private class |
ServersHT.Enumerator
A hashtable enumerator class.
|
private static class |
ServersHT.ServerDescEntry
Hashtable collision list.
|
Modifier and Type | Field and Description |
---|---|
private int |
count
The total number of entries in the hash table.
|
private static int |
initialCapacity
The default initial capacity for the hashtable: 13.
|
private static int |
KEYS |
private static float |
loadFactor
The default load factor for the hashtable: 0.75f.
|
private ServersHT.ServerDescEntry[] |
table
The hash table data.
|
private int |
threshold
The table is rehashed each time its size exceeds this threshold.
|
private static int |
VALUES |
Constructor and Description |
---|
ServersHT()
Constructs a new, empty hashtable with the default initial
capacity and load factor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this hashtable so that it contains no descriptors.
|
Enumeration<ServerDesc> |
elements()
Returns an enumeration of the server descriptors in this hashtable.
|
ServerDesc |
get(short sid)
Returns the descriptor of the corresponding server.
|
Enumeration<Short> |
keys()
Returns an enumeration of the keys (server id.) in this hashtable.
|
ServerDesc |
put(ServerDesc desc)
Maps the specified
desc in this hashtable. |
protected void |
rehash()
Increases the capacity of and internally reorganizes this
hashtable, in order to accommodate and access its entries more
efficiently.
|
ServerDesc |
remove(short sid)
Removes the descriptor from this hashtable.
|
int |
size()
Returns the number of entries in this hashtable.
|
String |
toString()
Returns a string representation of this Hashtable object.
|
private transient ServersHT.ServerDescEntry[] table
private transient int count
private static final int initialCapacity
private static final float loadFactor
private int threshold
private static final int KEYS
private static final int VALUES
public ServersHT()
public int size()
public Enumeration<Short> keys()
Enumeration
public Enumeration<ServerDesc> elements()
Enumeration
public ServerDesc get(short sid)
sid
- The server unique identification.protected void rehash()
public ServerDesc put(ServerDesc desc)
desc
in this hashtable.
The descriptor can be retrieved by calling the get
method with a key that is equal to the server id.desc
- the descriptor.null
if it did not have one.NullPointerException
- if the descriptor is null
.public ServerDesc remove(short sid)
sid
- the id of server that needs to be removed.null
if
it is not defined.public void clear()
Copyright © 2016 ScalAgent D.T.. All Rights Reserved.