1 package edu.berkeley.sbp;
4 import java.lang.reflect.*;
5 import java.lang.ref.*;
6 import edu.berkeley.sbp.util.*;
7 import edu.berkeley.sbp.*;
8 import edu.berkeley.sbp.*;
10 /** an element which matches exactly one input token */
11 public abstract class Atom<T extends Token> extends Element implements Topology<T> {
13 private final Topology<T> rt;
15 public Atom(Topology<T> rt) { this.rt = rt; }
17 Topology<T> top() { return rt; }
19 void reachable(HashSet<Sequence.Position> h) { /* do-nothing */ }
21 /** equality is based on the underlying <tt>Topology</tt> */
22 public int hashCode() { return rt.hashCode(); }
24 /** equality is based on the underlying <tt>Topology</tt> */
25 public boolean equals(Object o) { return o != null && o instanceof Atom && ((Atom)o).rt.equals(rt); }
27 /** declared abstract to force subclasses to override it in a useful manner */
28 public abstract String toString();
30 // Topology Thunks //////////////////////////////////////////////////////////////////////////////
32 public void add(Topology<T> t) { rt.add(t); }
33 public void add(T t) { rt.add(t); }
34 public void remove(Topology<T> t) { rt.remove(t); }
35 public void remove(T t) { rt.remove(t); }
36 public Topology<T> dup() { return rt.dup(); }
37 public boolean contains(T v) { return rt.contains(v); }
38 public Topology<T> fresh() { return rt.fresh(); }
39 public Topology<T> intersect(Topology<T> t) { return rt.intersect(t); }
40 public Topology<T> minus(Topology<T> t) { return rt.minus(t); }
41 public Topology<T> union(Topology<T> t) { return rt.union(t); }
42 public Topology<T> complement() { return rt.complement(); }
43 public boolean disjoint(Topology<T> t) { return rt.disjoint(t); }
44 public boolean containsAll(Topology<T> t) { return rt.containsAll(t); }