proj home

Files   Classes   Functions   Hierarchy  

cfcontainervec Class Reference

Similar to a map instance, string-compilationfile* pair with O(N) complexity with vector data structure. More...

#include <cfcontainervec.h>

Collaboration diagram for cfcontainervec:

List of all members.

Public Member Functions

void construct (uintc size)
 Not necessary for this data structure.
compilationfileoperator[] (stringc &filename) const
 Search.
boolc add (compilationfile *cf)
 Looks before adding the compilation file.
boolc remove (stringc &filename)
 If found, sets the pointer to zero.
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(N) complexity with vector data structure.

Both an iterator and an access similar to a map, its a just do it iterator. Its got terrible complexity O(N).

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 37 of file cfcontainervec.h.


Member Function Documentation

boolc cfcontainervec::add ( compilationfile cf  ) 

Looks before adding the compilation file.

Definition at line 22 of file cfcontainervec.cpp.

References compilationfile::filename.

00023 {
00024   assert(cf);
00025 
00026   //compilationfile* x = access(cf->filename);
00027   compilationfile* x = (*this)[cf->filename];
00028   if (x!=0)
00029     return false;
00030 
00031   vi.push_back(cf);
00032 
00033   return true;
00034 }

void cfcontainervec::construct ( uintc  size  )  [inline]

Not necessary for this data structure.

Definition at line 44 of file cfcontainervec.h.

00044 {};

boolc cfcontainervec::operator! (  ) 

Are there more elements?

Definition at line 41 of file cfcontainervec.cpp.

00042 {
00043   // As this operator is called before accessing and ++,
00044   //   it has the responsibility of incrementing to a valid state.
00045   uint currentmax=vi.size();
00046   if (current >=currentmax)
00047     return false;
00048   
00049   while (vi[current]==0)
00050   {
00051     ++current;
00052     if (current==currentmax)
00053       return false;
00054   }
00055 
00056   return true;
00057 
00058 /*
00059   while ((current<currentmax)&&(vi[current]==0))
00060   {
00061     ++current;
00062   }
00063 */
00064 
00065  // return (current < currentmax);
00066 }

compilationfile * cfcontainervec::operator() (  )  const

Access the current iterator element.

Definition at line 73 of file cfcontainervec.cpp.

00074 {
00075   assert(current < vi.size());
00076 
00077   return vi[current];
00078 }

void cfcontainervec::operator++ (  ) 

Increment.

Definition at line 68 of file cfcontainervec.cpp.

00069 {
00070   ++current;
00071 }

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

Search.

Definition at line 7 of file cfcontainervec.cpp.

00008 {
00009   uint imax=vi.size();
00010   for (uint i=0; i<imax; ++i)
00011   {
00012     if (!vi[i])
00013       continue;
00014 
00015     if (vi[i]->filename == filename)
00016       return vi[i];  
00017   }
00018 
00019   return 0;
00020 }

boolc cfcontainervec::remove ( stringc filename  ) 

If found, sets the pointer to zero.

Definition at line 80 of file cfcontainervec.cpp.

00081 {
00082 //cout << filename << endl; 
00083 //if (filename=="main.h")
00084 //  cout << "* main.h" << endl;
00085 
00086   uint imax=vi.size();
00087   for (uint i=0; i<imax; ++i)
00088   {
00089     if (!vi[i])
00090       continue;
00091 
00092     if (vi[i]->filename == filename)
00093     {
00094       vi[i] = 0;
00095       return true;
00096     } 
00097   }
00098 
00099   return false;
00100 }

void cfcontainervec::reset (  ) 

Reset the iterator.

Definition at line 36 of file cfcontainervec.cpp.

00037 {
00038   current=0;
00039 }


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