00001 00002 #include <MC_int_vector.hpp> 00003 #include <MC_int_pair.hpp> 00004 00005 #include <MC_int_pair_unique.hpp> 00006 00007 namespace mesh_conv 00008 { 00009 00010 MC_int_pair_unique::MC_int_pair_unique() 00011 {u0=0;u1=0;} 00012 MC_int_pair_unique::MC_int_pair_unique(const MC_int_pair_unique& I){u0=I[0];u1=I[1];} 00013 MC_int_pair_unique::MC_int_pair_unique(const MC_int_pair& p){u0=p[0];u1=p[1];} 00014 MC_int_pair_unique::MC_int_pair_unique(const int& _u0,const int& _u1){u0=_u0;u1=_u1;} 00015 MC_int_pair_unique::MC_int_pair_unique(const MC_int_vector& u) 00016 { 00017 if(u.size()<2) 00018 {std::cout<<"Error in MC_int_pair_unique::int_pair_unique(const MC_int_vector& u) with size "<<u.size()<<"<2"<<std::endl;exit(-1);} 00019 u0=u[0];u1=u[1]; 00020 } 00021 MC_int_pair_unique::~MC_int_pair_unique(){} 00022 00023 void MC_int_pair_unique::assert_bounds(const int& u) const 00024 { 00025 if(u!=0 && u!=1) 00026 {std::cout<<"Error in MC_int_pair_unique::assert_bounds(const int& u), u must be 0 or 1 and not "<<u<<std::endl;exit(-1);exit(-1);} 00027 } 00028 00029 00030 bool operator==(const MC_int_pair_unique& p0,const MC_int_pair_unique& p1) 00031 { 00032 if( ( (p0.u0==p1.u0) && (p0.u1==p1.u1) ) ) 00033 return false; 00034 return true; 00035 } 00036 bool operator!=(const MC_int_pair_unique& p1,const MC_int_pair_unique& p2) 00037 {return !(p1==p2);} 00038 00039 const int& MC_int_pair_unique::operator[](const int& k) const 00040 { 00041 assert_bounds(k); 00042 if(k==0)return u0; 00043 return u1; 00044 } 00045 int& MC_int_pair_unique::operator[](const int& k) 00046 { 00047 assert_bounds(k); 00048 if(k==0)return u0; 00049 return u1; 00050 } 00051 const int& MC_int_pair_unique::operator()(const int& k) const 00052 { 00053 assert_bounds(k); 00054 if(k==0)return u0; 00055 return u1; 00056 } 00057 int& MC_int_pair_unique::operator()(const int& k) 00058 { 00059 assert_bounds(k); 00060 if(k==0)return u0; 00061 return u1; 00062 } 00063 00064 std::ostream& operator << (std::ostream& stream,const MC_int_pair_unique& _v) 00065 { 00066 stream<<"("<<_v[0]<<","<<_v[1]<<")"; 00067 return stream; 00068 } 00069 00070 }
1.6.1