|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This defines the interface for a table that maps a symbol (integer id) to an array index. This is similar to a hashtable, except that allows for a couple domain specific interface level optimizations:
idx
where
0 <= idx <= Integer.MAX_VALUE
. This means that an
idx
value of -1
can be (and is) used by
get(int)
to indicate that the table doesn't contain the specified
symbol.
create(int)
operation.
SymbolMap
Field Summary | |
static int |
MIN_SYMBOL_ID
Currently the symbol id of zero is reserved for use by the symbol table implementation, and in the future could (hypothetically, at least) add more, therefore the minimum symbol id must be MIN_SYMBOL_ID . |
Method Summary | |
int |
create(int id)
Get the index that the specified symbol maps to, and create a new one if a mapping does not already exist. |
int |
get(int id)
Get the index that the specified symbol maps to. |
int |
size()
The number of mappings that exist in this table. |
java.util.Iterator |
symbols()
Return an iteration of the keys (symbols) into this table. |
Field Detail |
public static final int MIN_SYMBOL_ID
MIN_SYMBOL_ID
.
Method Detail |
public int get(int id)
id
- the id of the symbol to get a mapping for
-1
if no mapping exists for the
specified symbolpublic int create(int id)
id
- the id of the symbol to get a mapping for
public int size()
public java.util.Iterator symbols()
Iterator
interface, each symbol is wrapped (boxed)
in a Integer
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |