| oscript.util.SymbolTable
All known Subclasses: oscript.util.OpenHashSymbolTable,
SymbolTable | public interface SymbolTable (Code) | | 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:
- the value that a symbol maps to is an int
idx where
0 <= idx <= Integer.MAX_VALUE . This means that an
idx value of -1 can be (and is) used by
SymbolTable.get to indicate that the table doesn't contain the specified
symbol.
- since the table knows that the value of the next entry created
is equal to the last plus one (ie. the next successive array index)
the act of checking for the existance of a mapping (get), and
creating a new mapping if one doesn't already exist (put) can be
combined int a single
SymbolTable.create operation.
author: Rob Clark (rob@ti.com) version: 1.0 See Also: SymbolMap |
Field Summary | |
public 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 | |
public 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. | public int | get(int id) Get the index that the specified symbol maps to. | public int | size() The number of mappings that exist in this table. | public java.util.Iterator | symbols() Return an iteration of the keys (symbols) into this table. |
MIN_SYMBOL_ID | public static int MIN_SYMBOL_ID(Code) | | 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 .
|
create | public int create(int id)(Code) | | Get the index that the specified symbol maps to, and create a new one
if a mapping does not already exist. If a new mapping is created,
it's value is the next successive array index, ie. the the previous
array index plus one. The first mapping created has the value zero.
Parameters: id - the id of the symbol to get a mapping for an index |
get | public int get(int id)(Code) | | Get the index that the specified symbol maps to.
Parameters: id - the id of the symbol to get a mapping for an index, or -1 if no mapping exists for thespecified symbol |
size | public int size()(Code) | | The number of mappings that exist in this table.
the number of mappings in the table |
symbols | public java.util.Iterator symbols()(Code) | | Return an iteration of the keys (symbols) into this table. To conform to
the
java.util.Iterator interface, each symbol is wrapped (boxed)
in a
Integer .
an iteration of symbols that are keys into this table |
|
|