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 void reachable(HashSet<Sequence.Position> h) { /* do-nothing */ }
19 /** equality is based on the underlying <tt>Topology</tt> */
20 public int hashCode() { return rt.hashCode(); }
22 /** equality is based on the underlying <tt>Topology</tt> */
23 public boolean equals(Object o) { return o != null && o instanceof Atom && ((Atom)o).rt.equals(rt); }
25 /** declared abstract to force subclasses to override it in a useful manner */
26 public abstract String toString();
28 // Topology Thunks //////////////////////////////////////////////////////////////////////////////
30 public void add(Topology<T> t) { rt.add(t); }
31 public void add(T t) { rt.add(t); }
32 public void remove(Topology<T> t) { rt.remove(t); }
33 public void remove(T t) { rt.remove(t); }
34 public Topology<T> dup() { return rt.dup(); }
35 public boolean contains(T v) { return rt.contains(v); }
36 public Topology<T> fresh() { return rt.fresh(); }
37 public Topology<T> intersect(Topology<T> t) { return rt.intersect(t); }
38 public Topology<T> minus(Topology<T> t) { return rt.minus(t); }
39 public Topology<T> union(Topology<T> t) { return rt.union(t); }
40 public Topology<T> complement() { return rt.complement(); }
41 public boolean disjoint(Topology<T> t) { return rt.disjoint(t); }
42 public boolean containsAll(Topology<T> t) { return rt.containsAll(t); }