proj home

Files   Classes   Functions   Hierarchy  

regionD2linked.h

Go to the documentation of this file.
00001 #ifndef REGIOND2LINKED_H
00002 #define REGIOND2LINKED_H
00003 
00004 #include <cassert>
00005 #include <iostream>
00006 #include <sstream>
00007 #include <vector>
00008 using namespace std;
00009 
00010 #include <pnlink.h>
00011 #include <typedefs.h>
00012 
00013 template< typename Indx >
00014 class regionD2linked
00015 {
00016 public:
00017 
00018   typedef pnlink<Indx> link;
00019   typedef Indx const Indxc;
00020 
00021 
00023   link * start;
00024 
00025   regionD2linked();
00026 
00027   regionD2linked( Indxc p0, Indxc p1, Indxc n0, Indxc n1 )
00028     { start = new link(p0,p1,n0,n1); }
00029 
00030   regionD2linked( Indx p0, Indx p1, Indx p2, 
00031     Indx n0, Indx n1, Indx n2 )
00032     { start = new link(p0,p1,p2,n0,n1,n2); }
00033   regionD2linked( Indx p0, Indx p1, Indx p2, Indx p3,
00034     Indx n0, Indx n1, Indx n2, Indx n3 )
00035     { start = new link(p0,p1,p2,p3,n0,n1,n2,n3); }
00036   regionD2linked( Indx p0, Indx p1, Indx p2, Indx p3, Indx p4,
00037     Indx n0, Indx n1, Indx n2, Indx n3, Indx n4 )
00038     { start = new link(p0,p1,p2,p3,p4,n0,n1,n2,n3,n4); }
00039   regionD2linked( Indx p0, Indx p1, Indx p2, Indx p3, Indx p4, Indx p5,
00040     Indx n0, Indx n1, Indx n2, Indx n3, Indx n4, Indx n5 )
00041     { start = new link(p0,p1,p2,p3,p4,p5,n0,n1,n2,n3,n4,n5); }
00042   regionD2linked( Indx p0, Indx p1, Indx p2, Indx p3, Indx p4, Indx p5, Indx p6,
00043     Indx n0, Indx n1, Indx n2, Indx n3, Indx n4, Indx n5, Indx n6 )
00044     { start = new link(p0,p1,p2,p3,p4,p5,p6,n0,n1,n2,n3,n4,n5,n6); }
00045   regionD2linked( Indx p0, Indx p1, Indx p2, Indx p3, Indx p4, Indx p5, Indx p6, Indx p7,
00046     Indx n0, Indx n1, Indx n2, Indx n3, Indx n4, Indx n5, Indx n6, Indx n7 )
00047     { start = new link(p0,p1,p2,p3,p4,p5,p6,p7,n0,n1,n2,n3,n4,n5,n6,n7); }
00048 
00050   void vec( vector<Indx> & pi, vector<Indx> & ni ) const;  
00051 
00054   static bool writesize;
00055  
00057   operator string() const;
00058 
00060   boolc isnull() const
00061     { return start==0; }
00062 
00064   boolc add( Indx ptindex, Indx p0 )
00065     { assert(start!=0); return start->add(ptindex,p0); }
00066 
00067 };
00068 
00069 
00070 
00071   
00072 
00073 //---------------------------------------------------------
00074 // Implementation
00075 
00076 template< typename Indx >
00077 bool regionD2linked<Indx>::writesize = true;
00078 
00079 template< typename Indx >
00080 regionD2linked<Indx>::regionD2linked()
00081   : start(0) {}
00082 
00083 
00084 template< typename Indx >
00085 regionD2linked<Indx>::operator string() const
00086 {
00087   vector<Indx> pi;
00088   vector<Indx> ni;
00089   vec(pi,ni);
00090 
00091   string s;
00092   uint sz = pi.size();
00093   if (writesize)
00094   { 
00095     stringstream ss; 
00096     ss << sz; 
00097     s+=ss.str(); 
00098     s += "  "; 
00099   }
00100   for (uint i=0; i<sz; ++i)
00101   {
00102     { stringstream ss; ss << pi[i]; s+=ss.str(); }
00103     s += " ";
00104   }
00105 
00106   s += "  ";
00107 
00108   for (uint i=0; i<sz; ++i)
00109   {
00110     { stringstream ss; ss << ni[i]; s+=ss.str(); }
00111     s += " ";
00112   }
00113 
00114   return s;
00115 }
00116 
00117   
00118 
00119 template< typename Indx >
00120 void regionD2linked<Indx>::vec
00121 ( 
00122   vector<Indx> & pi, 
00123   vector<Indx> & ni 
00124 ) const
00125 {
00126   pi.clear();
00127   ni.clear();
00128 
00129   if (start==0)
00130     return;
00131 
00132   pi.push_back(start->plink);
00133   ni.push_back(start->nlink);
00134   
00135   link const * current = start->next;
00136   for ( ; current!=start; current=current->next )
00137   {
00138     pi.push_back(current->plink);
00139     ni.push_back(current->nlink);
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