de.spieleck.util
Class StringKeyHashtable
java.lang.Object
|
+--java.util.Dictionary
|
+--de.spieleck.util.SpeedHashtable
|
+--de.spieleck.util.StringKeyHashtable
- All Implemented Interfaces:
- java.io.Serializable
- public class StringKeyHashtable
- extends SpeedHashtable
This subclass of SpeedHashtable
is specially
taylored for the keys of Strings as keys in a Hashtable. The point
is to avoid the O(stringlen) calculation of the hashCode of
a String.
- See Also:
- Serialized Form
Field Summary |
static int |
EXP
|
protected static int |
LENGTH
|
Method Summary |
protected int |
hashCode(java.lang.Object o)
Replace the usual java hashCode for Strings by something
faster. |
static void |
main(java.lang.String[] args)
|
static int |
stringHashCode(java.lang.String s)
|
Methods inherited from class de.spieleck.util.SpeedHashtable |
append, clear, containsKey, elements, get, getElementSnap, getKeySnap, isEmpty, keys, put, remove, replaceLastGet, size, unsafePut |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EXP
public static final int EXP
LENGTH
protected static final int LENGTH
StringKeyHashtable
public StringKeyHashtable(int n)
StringKeyHashtable
public StringKeyHashtable()
hashCode
protected int hashCode(java.lang.Object o)
- Replace the usual java hashCode for Strings by something
faster. Note it is fairly easy to construct a sequence of
Strings which actually spoil this optimization by all having
the same hash. This is considered unlikely in real world
applications.
- Overrides:
hashCode
in class SpeedHashtable
stringHashCode
public static int stringHashCode(java.lang.String s)
main
public static void main(java.lang.String[] args)