proj home

Files   Classes   Functions   Hierarchy  

edgeT.h

Go to the documentation of this file.
00001 #ifndef EDGET_H
00002 #define EDGET_H
00003 
00004 #include <sstream>
00005 using namespace std;
00006 
00007 #include <typedefs.h>
00008 
00029 template< typename T >
00030 class edgeT
00031 {
00032 public:
00033 
00035   uint pi[2];
00037   T data;
00038 
00040   edgeT(uint i, uintc k, T const data_);
00042   edgeT(uint i, uintc k);
00043 
00045   boolc operator < (edgeT const & x) const;
00047   boolc operator == (edgeT const & x) const;
00048 
00050   operator stringc() const;
00051     
00052 };
00053 
00054 template< typename T >
00055 ostream & operator << (ostream & os, edgeT<T> const & x)
00056   { return os << (stringc)x; }
00057 
00058 //---------------------------------------------------------
00059 // Implementation
00060 
00061 template< typename T >
00062 edgeT<T>::operator stringc() const
00063 {
00064   stringstream targ;
00065   targ << pi[0] << " " << pi[1] << " " << data;
00066 
00067   return targ.str();
00068 }
00069 
00070 template< typename T >
00071 boolc edgeT<T>::operator == (edgeT const & x) const
00072 {
00073   if (pi[0]!=x.pi[0])
00074     return false;
00075   return (pi[1]==x.pi[1]);
00076 }
00077 
00078 template< typename T >
00079 boolc edgeT<T>::operator < (edgeT const & x) const
00080 {
00081   if (pi[0]<x.pi[0])
00082     return true;
00083 
00084   if (pi[0]==x.pi[0])
00085     return (pi[1]<x.pi[1]);
00086 
00087   return false;
00088 }
00089 
00090 
00091 template< typename T >
00092 edgeT<T>::edgeT(uint i, uintc k, T const data_)
00093   : data(data_)
00094 {
00095   if (i<k)
00096   {
00097     pi[0]=i;
00098     pi[1]=k;
00099   }
00100   else
00101   {
00102     pi[0]=k;
00103     pi[1]=i;
00104   }
00105 }
00106 
00107 template< typename T >
00108 edgeT<T>::edgeT(uint i, uintc k)
00109 {
00110   if (i<k)
00111   {
00112     pi[0]=i;
00113     pi[1]=k;
00114   }
00115   else
00116   {
00117     pi[0]=k;
00118     pi[1]=i;
00119   }
00120 }
00121 
00122   
00123 
00124 
00125 #endif
00126 

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