Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

cmt_vector Class Template Reference

#include <cmt_vector.h>

List of all members.

Public Types

typedef T element_type
typedef T* element_ptr
typedef T** frame_ptr

Public Methods

 cmt_vector ()
 cmt_vector (const cmt_vector& other)
 cmt_vector (int n)
 ~cmt_vector ()
void push_back (const T& object)
T& add ()
void pop_back ()
void erase (int index)
cmt_vector& operator= (const cmt_vector& other)
T& operator[] (int index) const
T& operator[] (int index)
T& back () const
T& back ()
void resize (int new_size)
int size () const
void clear ()
frame_ptr get_frame () const
int get_frame_number () const
int get_frame_size () const

Private Types

enum  { frame_size = 10 }

Private Methods

T& element_at (int index)
T& element_at (int index) const
int frames (int n)
void extend (int n)

Private Attributes

frame_ptr _data
int _frames
int _size


Member Typedef Documentation

template<classT>
typedef T* cmt_vector<T>::element_ptr
 

Definition at line 10 of file cmt_vector.h.

template<classT>
typedef T cmt_vector<T>::element_type
 

Definition at line 9 of file cmt_vector.h.

template<classT>
typedef T** cmt_vector<T>::frame_ptr
 

Definition at line 11 of file cmt_vector.h.


Member Enumeration Documentation

template<classT>
anonymous enum [private]
 

Enumeration values:
frame_size  

Definition at line 206 of file cmt_vector.h.

00206        { frame_size = 10 }


Constructor & Destructor Documentation

template<classT>
cmt_vector<T>::cmt_vector<T> ( ) [inline]
 

Definition at line 13 of file cmt_vector.h.

00014     {
00015       _data = 0;
00016       _frames = 0;
00017       _size = 0;
00018     }

template<classT>
cmt_vector<T>::cmt_vector<T> ( const cmt_vector<T> & other ) [inline]
 

Definition at line 20 of file cmt_vector.h.

00021     {
00022       _data = 0;
00023       _frames = 0;
00024       _size = 0;
00025 
00026       cmt_vector<T>& me = *this;
00027 
00028       extend (other._size);
00029       for (int i = 0; i < _size; i++)
00030         {
00031           me.element_at (i) = other.element_at (i);
00032         }
00033     }

template<classT>
cmt_vector<T>::cmt_vector<T> ( int n ) [inline]
 

Definition at line 35 of file cmt_vector.h.

00036     {
00037       _data = 0;
00038       _frames = 0;
00039       _size = 0;
00040 
00041       extend (n);
00042     }

template<classT>
cmt_vector<T>::~cmt_vector<T> ( ) [inline]
 

Definition at line 44 of file cmt_vector.h.

00045     {
00046       if (_data != 0)
00047         {
00048           for (int i = 0; i < _frames; i++)
00049             {
00050               delete[] _data[i];
00051               _data[i] = 0;
00052             }
00053 #ifdef CMT_USE_NEW_DELETE
00054           delete[] _data;
00055 #else
00056           free (_data);
00057 #endif
00058         }
00059       _data = 0;
00060       _frames = 0;
00061       _size = 0;
00062     }


Member Function Documentation

template<classT>
T & cmt_vector<T>::add ( ) [inline]
 

Definition at line 70 of file cmt_vector.h.

Referenced by Error::Error(), Libmap::add(), Tag::add(), Pattern::add(), Language::add(), Group::add(), Fragment::add(), Constituent::add(), Branch::add(), CmtSystem::add_cmt_path(), MakefileGenerator::analyze_document_file(), MakefileGenerator::analyze_file(), Use::create(), Symbol::create(), Use::current(), CmtSystem::scan_dir(), and CmtSystem::split().

00071     {
00072       resize (size() + 1);
00073       return (back ());
00074     }

template<classT>
T & cmt_vector<T>::back ( ) [inline]
 

Definition at line 157 of file cmt_vector.h.

00158     {
00159       if ((_data == 0) ||
00160           (_size == 0))
00161         {
00162           static T object;
00163           return (object);
00164         }
00165       else
00166         {
00167           return (element_at (_size - 1));
00168         }
00169     }

template<classT>
T & cmt_vector<T>::back ( ) const [inline]
 

Definition at line 143 of file cmt_vector.h.

Referenced by add().

00144     {
00145       if ((_data == 0) ||
00146           (_size == 0))
00147         {
00148           static T object;
00149           return (object);
00150         }
00151       else
00152         {
00153           return (element_at (_size - 1));
00154         }
00155     }

template<classT>
void cmt_vector<T>::clear ( ) [inline]
 

Definition at line 184 of file cmt_vector.h.

Referenced by MakefileGenerator::build_library_makefile(), Use::clear(), Tag::clear(), cmt_node_set::clear(), Use::clear_all(), Tag::clear_all(), Symbol::clear_all(), Pattern::clear_all(), Language::clear_all(), Group::clear_all(), Fragment::clear_all(), Constituent::clear_all(), Branch::clear_all(), CmtSystem::get_cmt_paths(), Use::get_paths(), operator=(), MakefileGenerator::reset(), CmtSystem::scan_dir(), and CmtSystem::split().

00185     {
00186       _size = 0;
00187     }

template<classT>
T & cmt_vector<T>::element_at ( int index ) const [inline, private]
 

Definition at line 214 of file cmt_vector.h.

00215     {
00216       int frame = index / frame_size;
00217       return (_data[frame][index % frame_size]);
00218     }

template<classT>
T & cmt_vector<T>::element_at ( int index ) [inline, private]
 

Definition at line 208 of file cmt_vector.h.

Referenced by back(), cmt_vector(), erase(), operator=(), operator[](), and push_back().

00209     {
00210       int frame = index / frame_size;
00211       return (_data[frame][index % frame_size]);
00212     }

template<classT>
void cmt_vector<T>::erase ( int index ) [inline]
 

Definition at line 81 of file cmt_vector.h.

Referenced by cmt_node_set::pop().

00082     {
00083       if ((_data == 0) ||
00084           (index < 0) ||
00085           (index >= _size))
00086         {
00087           return;
00088         }
00089 
00090       for (int i = index; i < (_size - 1); i++)
00091         {
00092           element_at (i) = element_at (i + 1);
00093         }
00094 
00095       _size--;
00096     }

template<classT>
void cmt_vector<T>::extend ( int n ) [inline, private]
 

Definition at line 225 of file cmt_vector.h.

Referenced by cmt_vector(), operator=(), push_back(), and resize().

00226     {
00227       if (n <= 0) return;
00228 
00229       _size += n;
00230 
00231       int f = frames (_size);
00232       if (f > _frames)
00233         {
00234           if (_data == 0)
00235             {
00236 
00237 #ifdef CMT_USE_NEW_DELETE
00238               _data = new element_ptr [f];
00239 #else
00240               _data = (frame_ptr) malloc (f * sizeof (element_ptr));
00241 #endif
00242 
00243             }
00244           else
00245             {
00246 
00247 #ifdef CMT_USE_NEW_DELETE
00248               frame_ptr new_data;
00249 
00250               new_data = new element_ptr [f];
00251               for (int i = 0; i < _frames; i++)
00252                 {
00253                   new_data[i] = _data[i];
00254                 }
00255               delete[] _data;
00256               _data = new_data;
00257 #else
00258               _data = (frame_ptr) realloc (_data, f * sizeof (element_ptr));
00259 #endif
00260 
00261             }
00262 
00263           for (int i = _frames; i < f; i++)
00264             {
00265               _data[i] = new T[frame_size];
00266             }
00267 
00268           _frames = f;
00269         }
00270     }

template<classT>
int cmt_vector<T>::frames ( int n ) [inline, private]
 

Definition at line 220 of file cmt_vector.h.

Referenced by extend().

00221     {
00222       return ((n == 0) ? 0 : ((n - 1) / frame_size) + 1);
00223     }

template<classT>
frame_ptr cmt_vector<T>::get_frame ( ) const [inline]
 

Definition at line 189 of file cmt_vector.h.

Referenced by dumper::dump_vector().

00190       {
00191         return (_data);
00192       }

template<classT>
int cmt_vector<T>::get_frame_number ( ) const [inline]
 

Definition at line 194 of file cmt_vector.h.

Referenced by dumper::dump_vector().

00195       {
00196         return (_frames);
00197       }

template<classT>
int cmt_vector<T>::get_frame_size ( ) const [inline]
 

Definition at line 199 of file cmt_vector.h.

Referenced by dumper::dump_vector().

00200       {
00201         return (frame_size);
00202       }

template<classT>
cmt_vector<T> & cmt_vector<T>::operator= ( const cmt_vector<T> & other ) [inline]
 

Definition at line 98 of file cmt_vector.h.

00099     {
00100       clear ();
00101 
00102       cmt_vector<T>& me = *this;
00103 
00104       extend (other._size);
00105       for (int i = 0; i < _size; i++)
00106         {
00107           element_at (i) = other.element_at (i);
00108         }
00109 
00110       return (me);
00111     }

template<classT>
T & cmt_vector<T>::operator[] ( int index ) [inline]
 

Definition at line 128 of file cmt_vector.h.

00129     {
00130       if ((_data == 0) ||
00131           (index < 0) ||
00132           (index >= _size))
00133         {
00134           static T object;
00135           return (object);
00136         }
00137       else
00138         {
00139           return (element_at (index));
00140         }
00141     }

template<classT>
T & cmt_vector<T>::operator[] ( int index ) const [inline]
 

Definition at line 113 of file cmt_vector.h.

00114     {
00115       if ((_data == 0) ||
00116           (index < 0) ||
00117           (index >= _size))
00118         {
00119           static T object;
00120           return (object);
00121         }
00122       else
00123         {
00124           return (element_at (index));
00125         }
00126     }

template<classT>
void cmt_vector<T>::pop_back ( ) [inline]
 

Definition at line 76 of file cmt_vector.h.

00077     {
00078       if (_size > 0) _size--;
00079     }

template<classT>
void cmt_vector<T>::push_back ( const T & object ) [inline]
 

Definition at line 64 of file cmt_vector.h.

Referenced by Use::add(), Tag::add(), Tag::add_tag_exclude(), Tag::add_tag_ref(), DependencyAnalyzer::add_use(), Use::get_paths(), cmt_node_set::push(), and cmt_and_node::reduce().

00065     {
00066       extend (1);
00067       element_at (_size - 1) = object;
00068     }

template<classT>
void cmt_vector<T>::resize ( int new_size ) [inline]
 

Definition at line 171 of file cmt_vector.h.

Referenced by add().

00172     {
00173       if (new_size < 0) return;
00174 
00175       extend (new_size - _size);
00176       _size = new_size;
00177     }

template<classT>
int cmt_vector<T>::size ( ) const [inline]
 

Definition at line 179 of file cmt_vector.h.

Referenced by Tag::action_exclude(), add(), Use::add(), CmtSystem::add_cmt_path(), add_cmt_paths_from_text(), Tag::add_tag_exclude(), Tag::add_tag_ref(), DependencyAnalyzer::add_use(), Symbol::all_print(), Symbol::all_print_clean(), Pattern::apply_all_globals(), Constituent::build_all_makefiles(), Constituent::build_all_msdev_files(), MakefileGenerator::build_document_makefile(), MakefileGenerator::build_library_makefile(), cmt_node_set::clear(), Use::clear_all(), Tag::clear_all(), Pattern::clear_all(), Language::clear_all(), Group::clear_all(), Fragment::clear_all(), Constituent::clear_all(), Branch::clear_all(), Use::create(), Use::current(), dumper::dump_vector(), ApplicationAnalyzer::end(), LibraryAnalyzer::end(), Use::fill_macro_all(), MakefileGenerator::fill_outputs(), Use::find(), Libmap::find(), Tag::find(), Symbol::find(), Pattern::find(), Language::find(), Group::find(), Fragment::find(), Variable::find(), Constituent::find(), Branch::find(), Language::find_with_suffix(), Libmap::find_with_trigger(), CmtSystem::get_cmt_paths(), Use::get_paths(), Use::get_selected_version(), use_action_iterator::get_use(), Use::is_client(), CmtSystem::is_package_directory(), Tag::mark(), cmt_or_node::match(), cmt_and_node::match(), CmtSystem::mkdir(), Use::move(), Use::need_new(), cmt_node_set::nodes(), Constituent::parse_all(), Pattern::pattern_number(), cmt_node_set::pop(), Branch::print_all(), cmt_and_node::reduce(), CmtSystem::remove_directory(), Use::reorder(), Tag::restore_tree(), UseAnalyzer::run(), Use::select_clients(), Use::set_auto_imports(), Language::setup_all_fragments(), Pattern::show(), Use::show_all(), Pattern::show_all(), Language::show_all(), Group::show_all(), Fragment::show_all(), Constituent::show_all(), Pattern::show_all_names(), Tag::show_definition(), Language::show_names(), Constituent::show_names(), Use::show_sub_uses(), Symbol::symbol_number(), Tag::tag_number(), cmt_node_set::top(), Use::undiscard_all(), Tag::unmark_all(), and Use::unselect_all().

00180     {
00181       return (_size);
00182     }


Member Data Documentation

template<classT>
frame_ptr cmt_vector<T>::_data [private]
 

Definition at line 272 of file cmt_vector.h.

template<classT>
int cmt_vector<T>::_frames [private]
 

Definition at line 273 of file cmt_vector.h.

template<classT>
int cmt_vector<T>::_size [private]
 

Definition at line 274 of file cmt_vector.h.


The documentation for this class was generated from the following file:
Generated at Thu May 16 16:27:44 2002 for CMT by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000