//
//	File:		    astl.h
//  Version:    ASTL 1.1
//	Copyright:	Vincent LE MAOUT
//	Date:		    Wed Dec 2 15:50:07 MET 1998
//	Descrition:	this file includes minimal set of ASTL headers
//              

#ifndef ASTL_1_1_H
#define ASTL_1_1_H

#include <iostream>
#include <functional>    // unary_function<>

// tag_traits<> definition +
// default tag
#include <tag.h>       

// skip_blanks_iterator implements DFA_*::const_iterator
// it skips holes in the pointer vector to internal states created by del_state
#include <iterator>
#include <vector>

template <class T>
class skip_blanks_iterator : public forward_iterator<vector<T*>::size_type, unsigned int>
{
  typedef skip_blanks_iterator self;

private:
  const vector<T*> *Q;
  vector<T*>::size_type pos;

public:  
  skip_blanks_iterator(const vector<T*> *_Q, 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);
  }
  
  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);
    }
};

// alphabet_traits<> definition +
// basic alphabets +
// default alphabet
#include <alphabet.h>  

/*
// allocators interface and implementations +
// default allocator
#ifndef WIN32
#include <astl_allocator.h> 
  typedef allocator_implementation_simple default_allocator;
#endif
*/
// base classes for DFA and NFA:
#include <fa_base.h>

template <class FA>
void stats(const FA &fa, ostream &out = cout)
{
  out << "FA has " << fa.state_count() << " states and " << fa.trans_count() 
      << " transitions" << endl;
}

// VC++ 5.0 does not define global operator != 
// guess what ? global operator templates don't work in most cases...
// have to define them as member functions, but just in case it might work :
#ifdef WIN32
  template <class T>
  inline
  bool operator != (const T &x, const T &y) {
    return !(x == y);
  }

// guess what ? Microsoft STL doesn't implements identity function (VC++ 6.0) :
// (needed for default behavior on Tags in DFA_compact)
template <class T>
struct identity : public unary_function<T, T>
{
	const T& operator () (const T &x) {
		return (x);
	}
};

#endif // WIN32

#endif // ASTL_1_1_H



