Files Classes Functions Hierarchy
00001 #ifndef SIMPLEXD2INDEXED_H 00002 #define SIMPLEXD2INDEXED_H 00003 00004 #include <typedefs.h> 00005 #include <sequencesequal.h> 00006 00007 00015 template< typename INDX=uint > 00016 class simplexD2indexed 00017 { 00018 public: 00019 00021 INDX pi[3]; 00022 00024 simplexD2indexed() 00025 { pi[0] = pi[1] = pi[2] = 0; } 00027 simplexD2indexed(INDX const a, INDX const b, INDX const c) 00028 { pi[0]=a; pi[1]=b; pi[2]=c; } 00029 00031 boolc operator == (simplexD2indexed<INDX> const & t) const; 00032 00034 void setnull() 00035 { pi[0] = pi[1] = pi[2] = 0; } 00037 boolc isnull() const; 00038 00040 ostream & print(ostream & os) const 00041 { return os << pi[0] << " " << pi[1] << " " << pi[2]; } 00042 00044 operator stringc () const; 00045 }; 00046 00047 template< typename INDX > 00048 ostream & operator << ( ostream & os, simplexD2indexed<INDX> const & s) 00049 { return s.print(os); } 00050 00051 //--------------------------------------------------------- 00052 // Implementation 00053 00054 template< typename INDX > 00055 simplexD2indexed<INDX>::operator stringc () const 00056 { 00057 stringstream ss; 00058 ss << pi[0] << " " << pi[1] << " " << pi[2]; 00059 return ss.str(); 00060 } 00061 00062 template< typename INDX > 00063 boolc simplexD2indexed<INDX>::operator == 00064 ( 00065 simplexD2indexed<INDX> const & t 00066 ) const 00067 { 00068 // for (uint k=0; k<3; ++k) 00069 // if (((pi[k]==t.pi[0])||(pi[k]==t.pi[1])||(pi[k]==t.pi[2]))==false) 00070 // return false; 00071 00072 return sequencesequal3(pi,t.pi); 00073 } 00074 00075 template< typename INDX > 00076 boolc simplexD2indexed<INDX>::isnull() const 00077 { 00078 // I have commented this out but I have no idea why I wrote this code. 00079 // It is here in case something breaks as continuous integration(the death star) 00080 // is not operational. 00081 /* 00082 if (pi[0]==0) 00083 return true; 00084 00085 if (pi[1]==0) 00086 return true; 00087 00088 if (pi[2]==0) 00089 return true; 00090 00091 return false; 00092 */ 00093 00094 if (pi[0]!=0) 00095 return false; 00096 00097 if (pi[1]!=0) 00098 return false; 00099 00100 if (pi[2]!=0) 00101 return false; 00102 00103 return true; 00104 } 00105 00106 00107 00108 #endif 00109 00110
1.5.8