chord.bddbddb
Class Dom<T>
java.lang.Object
chord.util.IndexMap<T>
chord.bddbddb.Dom<T>
- Type Parameters:
T - The type of values in the domain.
- All Implemented Interfaces:
- java.lang.Iterable<T>
- Direct Known Subclasses:
- ProgramDom
public class Dom<T>
- extends IndexMap<T>
Generic implementation of a BDD-based domain.
Typical usage is as follows:
- The domain is initialized by calling
setName(String)
which sets the name of the domain.
- The domain is next built in memory by repeatedly calling
IndexMap.getOrAdd(Object) with the argument in each call being a value
to be added to the domain. If the value already exists in the
domain then the call does not have any effect. Otherwise, the
value is mapped to integer K in the domain where K is the number
of values already in the domain.
- The domain built in memory is reflected onto disk by calling
save(String,boolean).
- The domain on disk can be read by a Datalog program.
- The domain in memory can be read by calling any of the
following:
IndexMap.iterator(), which provides an iterator over the
values in the domain in memory in the order in which they were
added,
IndexMap.get(int), which provides the value mapped to the
specified integer in the domain in memory, and
IndexMap.indexOf(Object), which provides the integer mapped to
the specified value in the domain in memory.
- Author:
- Mayur Naik (mhn@cs.stanford.edu)
|
Field Summary |
protected java.lang.String |
name
|
|
Constructor Summary |
Dom()
|
|
Method Summary |
boolean |
equals(java.lang.Object o)
|
java.lang.String |
getName()
|
int |
hashCode()
|
void |
print()
Prints the values in the domain in memory to the standard
output stream. |
void |
print(java.io.PrintStream out)
Prints the values in the domain in memory to the specified
output stream. |
void |
save(java.lang.String dirName,
boolean saveDomMap)
Reflects the domain in memory onto disk. |
void |
setName(java.lang.String name)
|
java.lang.String |
toUniqueString(int idx)
|
java.lang.String |
toUniqueString(T val)
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
name
protected java.lang.String name
Dom
public Dom()
setName
public void setName(java.lang.String name)
getName
public java.lang.String getName()
save
public void save(java.lang.String dirName,
boolean saveDomMap)
throws java.io.IOException
- Reflects the domain in memory onto disk.
- Throws:
java.io.IOException
toUniqueString
public java.lang.String toUniqueString(T val)
toUniqueString
public java.lang.String toUniqueString(int idx)
print
public void print()
- Prints the values in the domain in memory to the standard
output stream.
print
public void print(java.io.PrintStream out)
- Prints the values in the domain in memory to the specified
output stream.
- Parameters:
out - The output stream to which the values in the
domain in memory must be printed.
hashCode
public int hashCode()
- Overrides:
hashCode in class java.lang.Object
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals in class java.lang.Object