⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stream.h

📁 一个类似STL的自动机的源代码库
💻 H
字号:
/* * ASTL - the Automaton Standard Template Library. * C++ generic components for Finite State Automata handling. * Copyright (C) 2000-2003 Vincent Le Maout (vincent.lemaout@chello.fr). *  * This library 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.1 of the License, or (at your option) any later version. *  * This library 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 library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * */#ifndef ASTL_STREAM_H#define ASTL_STREAM_H#include <iostream>#include <set>#include <map>#include <stack>#include <utility>#include <cstdlib>   // abs()#include <astl.h>#include <cursor.h>#include <tag.h>#include <tools.h>#include <ccopy.h>using namespace std;#if (__GNUG__ && __GNUG__ > 2)using namespace rel_ops;#endifASTL_BEGIN_NAMESPACEclass DFA_stream{public:  typedef int state_type;  typedef state_type State;  struct bool_reference;  friend struct bool_reference;protected:  ostream &out;  set<state_type> F;  state_type count;public:  static const state_type null_state = 0;  DFA_stream(ostream &output)    : out(output), count(0)  { }  state_type new_state() {     return ++count;  }  struct bool_reference  {    State q;    DFA_stream &dfa;    bool_reference(State p, DFA_stream &a)      : q(p), dfa(a)    { }    bool_reference& operator= (bool b) {      if (b == true) dfa.F.insert(q);      return *this;    }  };  bool_reference final(State q) {    return bool_reference(q, *this);  }  template <class Alphabet>  void set_trans(State q, const Alphabet &a, State p) {    out << (F.find(q) != F.end() ? -q : q) << " " 	<< a << " " << (F.find(p) != F.end() ? -p : p) << endl;  }  void set_trans(state_type q, const char& a, state_type p) {    out << (F.find(q) != F.end() ? -q : q) << " " 	<< (int) a << " " << (F.find(p) != F.end() ? -p : p) << endl;  }  void set_trans(state_type q, const unsigned char& a, state_type p) {    out << (F.find(q) != F.end() ? -q : q) << " " 	<< (int) a << " " << (F.find(p) != F.end() ? -p : p) << endl;  }  void set_trans(state_type q, const string& a, state_type p) {    out << (F.find(q) != F.end() ? -q : q) << " \"" 	<< a << "\" " << (F.find(p) != F.end() ? -p : p) << endl;  }};template <typename DFirstCursor>ostream& dump(ostream &out, DFirstCursor first, DFirstCursor last = DFirstCursor()){  DFA_stream output(out);  clone(output, first);  return out;}ASTL_END_NAMESPACE#endif // ASTL_STREAM_ALGORITHMS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -