public abstract class SimpleHashtable extends Object
This class is not thread safe.
| Modifier and Type | Field and Description |
|---|---|
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)
|
| Modifier | Constructor and Description |
|---|---|
protected |
SimpleHashtable(RawPageSpace rps,
int logSize,
Extent es)
Create a new data table of a specified size.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
private static final int HASH_SHIFT
private static final Offset KEY_OFFSET
private static final Offset DATA_OFFSET
private final RawPageSpace space
private boolean valid
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.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 forpublic 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 entrypublic final Address getPayloadAddress(Word key)
key - The keypublic 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.