|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mmtk.utility.SimpleHashtable
public abstract class SimpleHashtable
This class implements a simple hashtable. It is intended for use in sanity checking or debugging, not high-performance algorithms.
This class is not thread safe.
Field Summary | |
---|---|
private Address |
base
The start address of the data table |
private static Offset |
DATA_OFFSET
Offset to the data |
private Extent |
entrySize
The size of each entry in the table |
private static int |
HASH_SHIFT
The number of low order bits to ignore |
private static Offset |
KEY_OFFSET
Offset to the key |
private Word |
mask
The mask to use to get the hash code |
private Extent |
size
The full size of the table |
private RawPageSpace |
space
The space to use for allocating the data structure |
private boolean |
valid
Is this table valid (created) |
Constructor Summary | |
---|---|
protected |
SimpleHashtable(RawPageSpace rps,
int logSize,
Extent es)
Create a new data table of a specified size. |
Method Summary | |
---|---|
void |
acquireTable()
Create a (zeroed) table. |
private int |
computeHash(Word key)
Compute the hashtable index for a given object. |
boolean |
contains(Word key)
Does the passed object have an entry in the table? |
private Address |
getEntry(int index)
Return the address of a specified entry in the table. |
Address |
getEntry(Word key,
boolean create)
Retrieve a pointer to the entry for the given object, or zero if one does not exist, unless create is passed. |
Address |
getFirst()
|
static Word |
getKey(Address entry)
Return the key for a given entry. |
Address |
getNext(Address curr)
The next element in the table after the passed entry, or null if it is the last entry. |
static Address |
getPayloadAddress(Address entry)
Given an address of an entry, return a pointer to the payload. |
Address |
getPayloadAddress(Word key)
Given a key, return a pointer to the payload. |
boolean |
isValid()
|
void |
releaseTable()
Drop the table (after collection). |
static void |
replaceKey(Address entry,
Word key)
Update the key for a given entry. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int HASH_SHIFT
private static final Offset KEY_OFFSET
private static final Offset DATA_OFFSET
private final Extent entrySize
private final Word mask
private Address base
private final Extent size
private final RawPageSpace space
private boolean valid
Constructor Detail |
---|
protected SimpleHashtable(RawPageSpace rps, int logSize, Extent es)
rps
- The space to acquire the data structure from.logSize
- The log of the number of table entries.es
- The size of each entry.Method Detail |
---|
public final void acquireTable()
public final void releaseTable()
public final boolean isValid()
public final Address getEntry(Word key, boolean create)
If create is true
, the return is guaranteed to be non-null
.
key
- The key used to lookup.create
- Create a new entry if not found.
null
.private int computeHash(Word key)
key
- The key.
private Address getEntry(int index)
index
- The index of the entry.
public final boolean contains(Word key)
key
- The key to find an entry for
public final Address getFirst()
public final Address getNext(Address curr)
curr
- The object to look for the next entry from.
null
.public static Address getPayloadAddress(Address entry)
entry
- The entry
public final Address getPayloadAddress(Word key)
key
- The key
public static Word getKey(Address entry)
entry
- The entry.
public static void replaceKey(Address entry, Word key)
entry
- The entry to update.key
- The new key.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |