proj home

Files   Classes   Functions   Hierarchy  

cfcontainerhash Class Reference

Similar to a map instance, string-compilationfile* pair with O(1) access with hash data structure. More...

#include <cfcontainerhash.h>

Collaboration diagram for cfcontainerhash:

List of all members.

Public Member Functions

 cfcontainerhash (uintc size=200)
 Constructor.
void construct (uintc size)
 Resize the container - invalidates previous memory.
compilationfileoperator[] (stringc &filename) const
 Search.
boolc add (compilationfile *cf)
 Looks before adding the compilation file.
boolc remove (stringc &filename)
 Remove the element.
void reset ()
 Reset the iterator.
boolc operator! ()
 Are there more elements?
void operator++ ()
 Increment.
compilationfileoperator() () const
 Access the current iterator element.


Detailed Description

Similar to a map instance, string-compilationfile* pair with O(1) access with hash data structure.

Implements interface

  // Resize the container.
  void construct(uintc size);
  // Search. 
  compilationfile* operator [] (stringc & filename) const;
  // Looks before adding the compilation file. 
  boolc add(compilationfile* cf);
  // Remove the element. 
  boolc remove(stringc & filename);
  // Reset the iterator. 
  void reset();
  // Are there more elements? 
  boolc operator ! ();
  // Increment. 
  void operator ++ ();
  // Access the current iterator element. 
  compilationfile* operator() () const;

Definition at line 33 of file cfcontainerhash.h.


Constructor & Destructor Documentation

cfcontainerhash::cfcontainerhash ( uintc  size = 200  ) 

Constructor.

Definition at line 8 of file cfcontainerhash.cpp.

00009   : ht(size,sphash), hti(ht)
00010 {
00011   vbl.reserve(size);
00012   vsp.reserve(size);
00013 }


Member Function Documentation

boolc cfcontainerhash::add ( compilationfile cf  ) 

Looks before adding the compilation file.

Definition at line 38 of file cfcontainerhash.cpp.

References hashtable< T, HFN >::contains(), compilationfile::filename, and hashtable< T, HFN >::insert().

Referenced by cfcontainerhashtest::test01().

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 }

void cfcontainerhash::construct ( uintc  size  ) 

Resize the container - invalidates previous memory.

Definition at line 15 of file cfcontainerhash.cpp.

References hashtable< T, HFN >::construct().

00016 {
00017   vbl.reserve(size);
00018   vsp.reserve(size);
00019   ht.construct(size);
00020 }

boolc cfcontainerhash::operator! (  ) 

Are there more elements?

Definition at line 74 of file cfcontainerhash.cpp.

00075 {
00076   return !hti;
00077 }

compilationfile * cfcontainerhash::operator() (  )  const

Access the current iterator element.

Definition at line 84 of file cfcontainerhash.cpp.

References bucketlink< T >::data.

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 }

void cfcontainerhash::operator++ (  ) 

Increment.

Definition at line 79 of file cfcontainerhash.cpp.

00080 {
00081   ++hti;
00082 }

compilationfile * cfcontainerhash::operator[] ( stringc filename  )  const

Search.

Definition at line 22 of file cfcontainerhash.cpp.

References stringpair< T >::data, bucketlink< T >::data, and hashtable< T, HFN >::insertInverse().

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 }

boolc cfcontainerhash::remove ( stringc filename  ) 

Remove the element.

Definition at line 58 of file cfcontainerhash.cpp.

References hashtable< T, HFN >::remove().

Referenced by cfcontainerhashtest::test01().

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 }

void cfcontainerhash::reset (  ) 

Reset the iterator.

Definition at line 69 of file cfcontainerhash.cpp.

References hashtableiterator< H >::reset().

Referenced by cfcontainerhashtest::test01().

00070 {
00071   hti.reset();
00072 }


The documentation for this class was generated from the following files:

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