public class SymbolTable extends Object
addSymbol
will always return the same string
reference.
The symbol table performs the same task as String.intern()
with the following differences:
Constructor and Description |
---|
SymbolTable()
Constructs a symbol table with a default number of buckets.
|
SymbolTable(int tableSize)
Constructs a symbol table with a specified number of buckets.
|
Modifier and Type | Method and Description |
---|---|
String |
addSymbol(char[] buffer,
int offset,
int length)
Adds the specified symbol to the symbol table and returns a
reference to the unique symbol.
|
int |
hash(char[] buffer,
int offset,
int length)
Returns a hashcode value for the specified symbol information.
|
public SymbolTable()
public SymbolTable(int tableSize)
tableSize
- The table size (default is 101)public String addSymbol(char[] buffer, int offset, int length)
buffer
- The buffer containing the new symbol.offset
- The offset into the buffer of the new symbol.length
- The length of the new symbol in the buffer.public int hash(char[] buffer, int offset, int length)
hash(String)
method when called
with the string object created from the symbol information.buffer
- The character buffer containing the symbol.offset
- The offset into the character buffer of the start
of the symbol.length
- The length of the symbol.Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.