package com.karneim.util.collection.set; /* * 01/07/2003 - 15:19:32 * * Automaton.java - * Copyright (C) 2003 Buero fuer Softwarearchitektur GbR InputStream* ralf.meyer@karneim.com * http://jrexx.sf.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ import java.io.*; import java.util.*; /** * DFASet is an immutable Set of strings based on a minimized deterministic automaton (DFA). * @author Ralf Meyer */ public class DFASet { protected static class State { protected static class Transition { protected final CharSet charSet; protected final int toState; protected Transition(CharSet charSet,int toState) { this.charSet = charSet; this.toState = toState; } } protected final boolean isFinal; protected final Transition[] transitions; protected State(boolean isFinal,Transition[] transitions) { this.isFinal = isFinal; this.transitions = transitions; } } protected final State[] states; protected final Integer startState; protected DFASet(State[] states,Integer startState) { this.states = states; this.startState = startState; } public DFASet(FSAData automaton) { if (automaton==null) throw new IllegalArgumentException("automaton==null"); HashMap map = new HashMap(); State[] newStates = new State[automaton.states==null ? 0 : automaton.states.length]; for (int i=0; i0; ++offset, --length) { for (int i=0; i0; ++offset, --length) { for (int i=0; i