oscript.util
Interface SymbolTable

All Known Implementing Classes:
OpenHashSymbolTable

public interface SymbolTable

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:

Version:
1.0
Author:
Rob Clark (rob@ti.com)
See Also:
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

MIN_SYMBOL_ID

public static final 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.

See Also:
Constant Field Values
Method Detail

get

public int get(int id)
Get the index that the specified symbol maps to.

Parameters:
id - the id of the symbol to get a mapping for
Returns:
an index, or -1 if no mapping exists for the specified symbol

create

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. 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
Returns:
an index

size

public int size()
The number of mappings that exist in this table.

Returns:
the number of mappings in the table

symbols

public java.util.Iterator symbols()
Return an iteration of the keys (symbols) into this table. To conform to the Iterator interface, each symbol is wrapped (boxed) in a Integer.

Returns:
an iteration of symbols that are keys into this table