proj home

Files   Classes   Functions   Hierarchy  

sequencesequal.h

Go to the documentation of this file.
00001 #ifndef SEQUENCESEQUAL_H
00002 #define SEQUENCESEQUAL_H
00003 
00004 #include <typedefs.h>
00005 
00008 template< typename INDX>
00009 boolc sequencesequal3(INDX const* va, INDX const* vb);
00010 
00011 //<TODO> expand for 4 and general N
00012 
00013 //---------------------------------------------------------
00014 // Implementation
00015 
00016 
00017 template< typename INDX, uint I0, uint I1, uint I2 >
00018 class sequencesequal3helper
00019 {
00020 public:
00021 
00022   boolc eval(INDX const* va, INDX const* vb) const;
00023 };
00024 
00025 
00026 template< typename INDX, uint I0, uint I1, uint I2 >
00027 boolc sequencesequal3helper<INDX,I0,I1,I2>::eval
00028 (
00029   INDX const* va, 
00030   INDX const* vb
00031 ) const
00032 {
00033   if (va[I0]==vb[I0])
00034   {
00035     if (va[I1]==vb[I1])
00036     {
00037       if (va[I2]==vb[I2])
00038         return true;
00039     
00040       return false;
00041     }
00042 
00043     if (va[I1]==vb[I2])
00044     {
00045       if (va[I2]==vb[I1])
00046         return true;
00047     
00048       return false;
00049     }
00050     
00051     return false;
00052   }
00053 
00054   return false;
00055 }
00056 
00057 template< typename INDX>
00058 boolc sequencesequal3(INDX const* va, INDX const* vb)
00059 {
00060 
00061   if (sequencesequal3helper<INDX,0,1,2>().eval(va,vb)==true)
00062     return true;
00063 
00064   if (sequencesequal3helper<INDX,2,1,0>().eval(va,vb)==true)
00065     return true;
00066 
00067   if (sequencesequal3helper<INDX,1,0,2>().eval(va,vb)==true)
00068     return true;
00069 
00070   return false;
00071 
00072 /*
00073 
00074   if (va[0]==vb[0])
00075   {
00076     if (va[1]==vb[1])
00077     {
00078       if (va[2]==vb[2])
00079         return true;
00080     
00081       return false;
00082     }
00083 
00084     if (va[1]==vb[2])
00085     {
00086       if (va[2]==vb[1])
00087         return true;
00088     
00089       return false;
00090     }
00091     
00092     return false;
00093   }
00094 
00095 
00096   if (va[1]==vb[0])
00097   {
00098     if (va[0]==vb[1])
00099     {
00100       if (va[2]==vb[2])
00101         return true;
00102     
00103       return false;
00104     }
00105 
00106     if (va[0]==vb[2])
00107     {
00108       if (va[2]==vb[1])
00109         return true;
00110     
00111       return false;
00112     }
00113     
00114     return false;
00115   }
00116 
00117 
00118   if (va[2]==vb[0])
00119   {
00120     if (va[1]==vb[1])
00121     {
00122       if (va[0]==vb[2])
00123         return true;
00124     
00125       return false;
00126     }
00127 
00128     if (va[1]==vb[2])
00129     {
00130       if (va[0]==vb[1])
00131         return true;
00132     
00133       return false;
00134     }
00135     
00136     return false;
00137   }
00138 
00139   return false;
00140 */
00141 
00142 }
00143 
00144 
00145 #endif
00146 
00147 

Generated on Fri Mar 4 00:49:26 2011 for Chelton Evans Source by  doxygen 1.5.8