// getInstance will return a Node but possibly not a Star // if the child is an emptyString, return emptyString public static Node getInstance(Node child) { if (child == EmptySet.getInstance()) return child; if (!map.containsKey(child)) { map.put(child, new Star(child)); } return map.get(child); }
@Override public Node visit(Symbol node) { // Dc(c) = "" if (c == node.symbol) return EmptyString.getInstance(); // Do the same thing for the empty string // Dc(c') = 0 if c is not c' else return EmptySet.getInstance(); }
@Override public Node visit(EmptyString node) { // Dc("") = 0 return EmptySet.getInstance(); }