📄 astl.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_H#define ASTL_H#ifdef USE_ASTL_NAMESPACE#define ASTL_BEGIN_NAMESPACE namespace astl {#define ASTL_END_NAMESPACE }#else#define ASTL_BEGIN_NAMESPACE#define ASTL_END_NAMESPACE#endif#include <vector>#include <utility> // relops#include <iterator>#include <functional>using namespace std;#ifdef _MSC_VER// don't know why this pragma does not work:#pragma warning( disable : 4786 ) // identifier was truncated to 255 characters...// don't understand this warning, let's kill it:#pragma warning( disable : 4800 ) // forcing value to bool true or false (performance warning)#pragma warning( disable : 4530 ) // C++ exception handler used but unwind semantics disabled...#endifASTL_BEGIN_NAMESPACE#include <alphabet.h> #include <concept.h>#include <tag.h>// skip_blanks_iterator implements DFA_*::const_iterator// it skips holes in the pointers vector to internal states created by del_statetemplate <typename T>#if (__GNUG__ && __GNUG__ < 3)class skip_blanks_iterator : public forward_iterator<typename vector<T*>::size_type, ptrdiff_t>#elseclass skip_blanks_iterator : public iterator<forward_iterator_tag, typename vector<T*>::size_type>#endif{ typedef skip_blanks_iterator self;private: const vector<T*> *Q; typename vector<T*>::size_type pos;public: skip_blanks_iterator(const vector<T*> *_Q, typename vector<T*>::size_type _pos) : Q(_Q), pos(_pos) { } skip_blanks_iterator() : Q(NULL), pos(0) { } skip_blanks_iterator(const self &x) : Q(x.Q), pos(x.pos) { } self& operator = (const self &x) { Q = x.Q; pos = x.pos; return (*this); } bool operator == (const self &x) { return (x.pos == pos && x.Q == Q); } bool operator != (const self &x) { return (x.pos != pos || x.Q != Q); } typename vector<T*>::size_type operator * () { return (pos); } self& operator ++ () { for(++pos; pos < Q->size() && Q->operator[](pos) == NULL; ++pos); return (*this); } self operator ++ (int) { self tmp = *this; ++(*this); return (tmp); }};ASTL_END_NAMESPACE#ifdef __GNUG__#if (__GNUG__ < 3)#include <functional>#else#include <ext/functional>#endif#elsetemplate <class Pair>struct select1st : public unary_function<Pair, typename Pair::first_type>{ const typename Pair::first_type& operator()(const Pair& x) const { return x.first; }};template <class Pair>struct select2nd : public unary_function<Pair, typename Pair::second_type>{ const typename Pair::second_type& operator()(const Pair& x) const { return x.second; }};template <typename T>struct identity : public unary_function<T, T>{ const T& operator()(const T &x) const { return x; }};#endiftemplate <typename T, typename U>inlinebool operator==(const pair<const T, U> &x, const pair<T, U> &y) { return x.first == y.first && x.second == y.second;}#ifndef _MSC_VERtemplate <typename T, typename U>inlinebool operator==(const pair<T, U> &x, const pair<const T, U> &y) { return x.first == y.first && x.second == y.second;}#endif#endif // ASTL_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -