public class SymbolTable extends Object
Constructor and Description |
---|
SymbolTable()
Default constructor
|
SymbolTable(int start)
Use this constructor if you need your symbol numbering to start at a different point than 0.
|
SymbolTable(String[] names)
Init the symbol table from an array of strings, where code points correspond to array
positions.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String symbol) |
SymbolTable |
copy()
Perform a deep copy.
|
int |
get(String symbol)
Get value of symbol in table.
|
int |
getStart()
Get the starting number of the symbol table.
|
String |
getSymbol(int i)
Find the symbol corresponding to a value.
|
static SymbolTable |
readFromFile(String filename)
Read a file line by line, and create an entry for each line.
|
int |
set(String symbol)
Create new symbol in table.
|
int |
size()
Returns number of symbols in table.
|
String |
toString()
Returns the string representation of the internal hash table.
|
public SymbolTable(int start)
start
- The code point of the first symbol added to the table. Subsequent symbols will have
larger code points.public SymbolTable()
public SymbolTable(String[] names)
names
- The String array containing the symbols.public boolean contains(String symbol)
public int getStart()
public SymbolTable copy()
this
.public int set(String symbol)
symbol
- the input string to be put in the table.public int get(String symbol)
symbol
- the input string.start-1
, else
(where start
is the code point of the first symbol).public String getSymbol(int i)
i
- the number that we want to get the string value for.public int size()
public String toString()
public static SymbolTable readFromFile(String filename) throws IOException
filename
- The name of the file to be read in.IOException
- Errors reading in the file.Copyright © 2006–2023 The Apache Software Foundation. All rights reserved.