synaps/mpol/Lex.h

00001 /*********************************************************************
00002 *      This file is part of the source code of SYNAPS kernel.        *
00003 *   Author(s): B. Mourrain, GALAAD, INRIA                            *
00004 **********************************************************************
00005 History: 
00006 $Id: Lex.h,v 1.1 2005/07/11 11:17:56 mourrain Exp $
00007 **********************************************************************/
00008 #ifndef SYNAPS_MPOL_LEX_H
00009 #define SYNAPS_MPOL_LEX_H
00010 
00011 #include <synaps/init.h>
00012 
00013 __BEGIN_NAMESPACE_SYNAPS
00014 
00018 struct Lex
00019 {
00020   template <class M>
00021   static bool less (const M &, const M &);
00022   template <class M>
00023   bool operator() (const M & m1, const M & m2) const {return less(m1,m2);}
00024 };
00025 
00026 template <class M>
00027 inline bool Lex::less(const M & m1, const M & m2) 
00028 {
00029    int n1 = m1.nvars(), n2 =m2.nvars();
00030    int i = 0;
00031 
00032    if(std::max(n1,n2)<0)
00033      return false;
00034    else
00035      {
00036        while(m1[i] == m2[i] && i< n1+1&& i<n2+1) i++;
00037        if(i==n2+1) 
00038          return false;
00039        else if(i==n1+1)
00040          return true;
00041        else
00042          return (m1[i]< m2[i]);
00043      }
00044 }
00045 
00046 __END_NAMESPACE_SYNAPS
00047 #endif // SYNAPS_MPOL_LEX_H
00048 

SYNAPS DOCUMENTATION
logo