public class SymbolTable
extends java.lang.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(java.lang.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(java.lang.String symbol) |
SymbolTable |
copy()
Perform a deep copy.
|
int |
get(java.lang.String symbol)
Get value of symbol in table.
|
int |
getStart()
Get the starting number of the symbol table.
|
java.lang.String |
getSymbol(int i)
Find the symbol corresponding to a value.
|
static SymbolTable |
readFromFile(java.lang.String filename)
Read a file line by line, and create an entry for each line.
|
int |
set(java.lang.String symbol)
Create new symbol in table.
|
int |
size()
Returns number of symbols in table.
|
java.lang.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(java.lang.String[] names)
names
- The String array containing the symbols.public boolean contains(java.lang.String symbol)
public int getStart()
public SymbolTable copy()
this
.public int set(java.lang.String symbol)
symbol
- the input string to be put in the table.public int get(java.lang.String symbol)
symbol
- the input string.start-1
, else
(where start
is the code point of the first symbol).public java.lang.String getSymbol(int i)
i
- the number that we want to get the string value for.public int size()
public java.lang.String toString()
toString
in class java.lang.Object
public static SymbolTable readFromFile(java.lang.String filename) throws java.io.IOException
filename
- The name of the file to be read in.java.io.IOException
- Errors reading in the file.Copyright © 2013. All Rights Reserved.