mset_operators.h

00001 /*
00002  *  Copyright (C) 2005 M.J. Zaki <zaki@cs.rpi.edu> Rensselaer Polytechnic Institute
00003  *  Written by parimi@cs.rpi.edu
00004  *  Updated by chaojv@cs.rpi.edu, alhasan@cs.rpi.edu, salems@cs.rpi.edu
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00019  */
00020 #ifndef _MSET_OPERATORS_H_
00021 #define _MSET_OPERATORS_H_
00022 
00023 #include<ostream>
00024 using namespace std;
00025 
00026 #include "typedefs.h"
00027 
00028 template<class PP, class MP, class ST, template<class, typename, typename, template <typename> class> class CC, 
00029          template <typename> class ALLOC >
00030 class pattern;
00031 
00032 template<class PP, class MP, class PAT_ST, template<typename, typename, typename, template <typename> class> class CC,
00033          template <typename> class ALLOC >
00034 ostream& operator<< (ostream& ostr, const MSET_PATTERN* p) {
00035   typename MSET_PATTERN::CONST_IT it;
00036 
00037   for(it=p->begin(); it!=p->end(); it++) {
00038 
00039     if(it == p->begin()) {
00040       ostr << (*it).v;
00041     } else {
00042       ostr << " " << (*it).v;
00043     }
00044   }
00045 
00046    ostr <<" -- "<<p->_pat_sup; 
00047 
00048    return ostr;
00049 }
00050 
00051 #include "pattern.h"
00052 
00053 
00054 template<class PP, class MP, class PAT_ST, template<class, typename, typename, template <typename> class> class CC,
00055          template <typename> class ALLOC >
00056 bool pattern<PP,MP,PAT_ST,CC, ALLOC>::operator< (const pattern<PP,MP,PAT_ST,CC, ALLOC> rhs) const {
00057 
00058   CONST_IT it=begin(), rhs_it=rhs.begin();
00059 
00060   if(size()!=rhs.size()) {
00061     cerr<<"Sequences are not of the same size."<<endl;
00062     exit(0);
00063   }
00064 
00065   while(it!=end() && rhs_it!=rhs.end()) {
00066     if((*it).v != (*rhs_it).v)
00067       return (*it) < (*rhs_it);
00068 
00069     it++;
00070     rhs_it++;
00071   }//end outer while
00072   
00073   //if execuion reaches this point then sequences are equal
00074   return false;
00075 }
00076 
00077 #endif

Generated on Wed Jul 26 14:01:08 2006 for DMTL by  doxygen 1.4.7