| java.lang.Object oscript.util.OpenHashSymbolTable
OpenHashSymbolTable | public class OpenHashSymbolTable implements SymbolTable,java.io.Externalizable(Code) | | A symbol table implementation based on a open hash map, using double
hashing as a strategy to avoid collisions. Double hasing uses two hash
functions to compute an index into the table:
Idx(i,k) := H1(k) + i * H2(k)
where for a given key k , i is incremented from
0 until an unused table slot is found.
Threading note: this class is not synchronized, but is designed to
save to read from multiple threads, while write from a single thread
context (at a time).
author: Rob Clark (rob@ti.com) version: 1.0 |
OpenHashSymbolTable | public OpenHashSymbolTable()(Code) | | Class Constructor.
|
OpenHashSymbolTable | public OpenHashSymbolTable(int capacity, float load)(Code) | | Class Constructor.
Parameters: capacity - the initial capacity Parameters: load - the loading factor |
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 | final 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 |
getLoad | public float getLoad()(Code) | | |
getStats | final public static synchronized String getStats()(Code) | | |
size | public int size()(Code) | | The number of mappings that exist in this table.
the number of mappings in the table |
symbols | public synchronized 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 |
|
|