proj home

Files   Classes   Functions   Hierarchy  

cfcontainerhash.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 using namespace std;
00003 
00004 
00005 #include <cfcontainerhash.h>
00006 #include <print.h>
00007 
00008 cfcontainerhash::cfcontainerhash(uintc size)
00009   : ht(size,sphash), hti(ht)
00010 {
00011   vbl.reserve(size);
00012   vsp.reserve(size);
00013 }
00014 
00015 void cfcontainerhash::construct(uintc size)
00016 {
00017   vbl.reserve(size);
00018   vsp.reserve(size);
00019   ht.construct(size);
00020 }
00021 
00022 compilationfile* cfcontainerhash::operator [] (stringc & filename) const
00023 {
00024   sp x1(filename,0); 
00025 
00026   blink* p = ht.insertInverse(x1);
00027 
00028   if (!p)
00029   {
00030     //cout << "could not find " << filename << endl;
00031     return 0;
00032   }
00033 
00034   return p->data->data;
00035 }
00036 
00037 
00038 boolc cfcontainerhash::add(compilationfile* cf)
00039 {
00040   assert(cf);
00041 
00042   vsp.push_back( sp(cf->filename,cf) );
00043   sp* x = & vsp[vsp.size()-1];
00044 
00045 
00046   if (ht.contains(*x))
00047     return false;
00048 
00049   vbl.push_back( blink( x ) );
00050   blink* x2 = & vbl[vbl.size()-1];
00051 
00052   ht.insert(x2);
00053 
00054   return true;
00055 }
00056 
00057 
00058 boolc cfcontainerhash::remove(stringc & filename)
00059 {
00060 //cout << filename << endl; 
00061 //if (filename=="main.h")
00062 //  cout << "* main.h" << endl;
00063 
00064   sp x1(filename,0); 
00065   return ht.remove(x1);
00066 }
00067 
00068 
00069 void cfcontainerhash::reset()
00070 {
00071   hti.reset();
00072 }
00073 
00074 boolc cfcontainerhash::operator ! ()
00075 {
00076   return !hti;
00077 }
00078 
00079 void cfcontainerhash::operator ++ ()
00080 {
00081   ++hti;
00082 }
00083 
00084 compilationfile* cfcontainerhash::operator() () const
00085 {
00086   #ifndef NDEBUG
00087   blink* bl = hti();
00088   assert(bl);
00089   #endif
00090   //assert(hti());
00091   //cout << SHOW(bl) << endl;
00092   //cout << SHOW(bl->data) << " " << SHOW(bl->next) << endl;
00093   //sp* x = bl->data; 
00094   assert(bl->data);
00095   //cout << SHOW(x->data);
00096   //assert(hti()->data);
00097   return hti()->data->data;
00098 }
00099 

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